Conjugate heat transfer of simple geometries - comparison with exp data

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
jgd23
Posts: 141
Joined: Mon Jun 06, 2016 10:00 am

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by jgd23 »

Second topic,

I want to use the frozen velocity field at 150 degC to start a transient simulation for heating the steel cylinder inside the fluid volume.
I see that there is an option where I can restart the simulation since a checkpoint + option the have a frozen dynamic.

I try this but I don't have results. I change in the initial temperature of the solid to ambiant temperature = 20 degC.
I switch to adaptative time step. I increase the Fourier number to 50, max time step to 1 s, iteration to 7500.

When I start the simulation, the convergence tool gives me no curve, the monitoring point in the solid volume gives me a constant 150 degC.

Do you know how I can arrange things to start at 20 degC in a frozen flow at 150 degC and measure the heating of the steel cylinder?
How can I measure with the GUI the volume average temperature for post process?

Best regards

Julien
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by Yvan Fournier »

Hello,

This would be clearer with a schematic...

An as usual, at least part of the info in the forum usage recommendations would obviously keep me from guessing too many things.

Regards,

Yvan
jgd23
Posts: 141
Joined: Mon Jun 06, 2016 10:00 am

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by jgd23 »

Hello Yvan,

Sorry for the lack of information of my previous post

The case:
To resume, I want to simulation the heating time of a steel cylinder in air forced convection ambiance (at different velocities), the natural convection is neglected.
I have already done simulations with CHT OpenFoam solver and experimental measurements. (See my first post with the results)
I want to use CS for comparison and use it in the future because of the GUI and all the user friendly tools you have developed with CS.

The strategy:
First I calculate the stationary air stream with air parameters fixed at 150 degC (rho = constant, conductivity = constant, Cp = constant). The initial temperature of the steel cylinder is taken at 150 degC to improve the convergence speed.
Secondly I use as checkpoint the frozen flow and measure the transient heating time of the steel part, initial temperature of the steel cylinder is 20 degC.

The simulation parameters:
Please see the Mesh + velocity results to have a better understanding of my case.
Turbulence parameters are:
Re number = 8200
y+ = 1 is 0.0002 m (my first cell BL is 0.00017 m)
I choose kwSST with y+ around 1 (all y+ option) in stationary simulation with conservative parameters.

- First question about convergence of the air stream simulation:
I obtain some results but the convergence is not achieved. I use monitoring points in the fluid domain and I see that the values are constants after 400 iterations. See the convergence image attached.
I run this case on different meshes density and it gives the same characteristic values of velocities, k, omega etc...
Should I conclude that the convergence is reached ?

- Second question about the restart for the transient steel part heating simulation
I see that there is an option where I can restart the simulation at a checkpoint + option to have a frozen dynamic field.
I change the initial temperature of the solid to ambiant temperature = 20 degC.

The transient parameters are :
Adaptative time step
Fourier number to 50
max time step to 1 s
iteration to 7500

When I start the simulation, the convergence tool gives me no curve, the monitoring point in the solid volume gives me a constant 150 degC.
Do you know how I can arrange things to start at 20 degC in a frozen flow and measure the heating time of the steel cylinder?

- Third question:
How can I measure with the GUI the volume average temperature of the steel cylinder in post process ?

Best regards

Julien
Attachments
image_velocityX.png
Screenshot from 2022-11-27 09-20-16.png
Screenshot from 2022-11-27 09-18-07.png
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by Yvan Fournier »

Hello,

Are you using internal coupling or Syrthes for conjugate heat transfer ?

I am not sure about why the monitoring tool shows nothing (what do you have in the monitoring folder ?), but in any case, if you are using only the GUI, your change if initialization will be ignored for all restarts.

To really change initial temperature values after restart, you need to use cs_user_initialization.c. Relative to the examples, you can remove the test that usually ensures we do not overwrite restarted values with initialization (since you want to do exactly that), and change only the temperature values.

As to your question about mesh convergence, yes, if you see no change relative to mesh refinement, that would tend to mean you have attained mesh convergence, though your mesh seems quite coarse (is it the coarsest one ?) and the choice of wall law might also have some influence.

Regards,

Yvan
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by Antech »

Hello, jgd23
Regarding convergence control. We usually don't look at standard residual monitors because they say nothing practical too often. Instead of this, we control:
1. Monitors of averages, minimum and maximum at characteristic points, sections or volumes. It's easily done in Fluent or CFX, but with Saturne, IMHO, it's a problem. First, it only monitors points, as I know (I almost always use slice or volume ave, not points). Second, it doesn't flush file buffers so monitor file is not up-to-date after many iterations, so we need to create empty control_file to force flush buffers (maybe fixed in newer versions). That's why I often just check number of iterations (150...300 for pure aerodynamic with static + adaptive/variable volume time step with target CFL=1...5) and maximal pressure/temperature.
I think that volume/surface monitors can be introduced via user functions, but it requires additional coding to make universal tool (set section / volume names and variables => get monitors).
2. Periodical field check in control sections. Catalyst setup is ideal for this, but it's very hard and custom to compile. So I usually use simpler method: in Writer properties in GUI you can set periodical output and open results every N iterations. Earlier I used Catalyst setups, very useful, but requires lots of time to configure.

Regarding mesh: yes, if results doesn't change with mesh cell size you can stay with coarser mesh to save calculation time. Temperature or heat flux change with switching from SST/Layers to k-epsilon/No-layers is interesting (I didn't try this).
jgd23
Posts: 141
Joined: Mon Jun 06, 2016 10:00 am

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by jgd23 »

Hello,

I use internal coupling for the conjugate heat transfer.

I have follow your advice with the initialization with user-function and it works.

Code: Select all

void 
cs_user_initialization(cs_domain_t     *domain)
{
  const cs_mesh_t *m = domain->mesh;

  /* If this is restarted computation, do not reinitialize values */
  /*if (domain->time_step->nt_prev > 0)
   /* return;

  /* Initialize "scalar1" field to 25 only if it exists  */
  cs_field_t *f = cs_field_by_name_try("temperature");

  if (f != NULL) {
    for (cs_lnum_t cell_id = 0; cell_id < m->n_cells; cell_id++)
      f->val[cell_id] = 20.;
  }
}
I don't exactly know how to proceed to select only the solid domain for the initialization after the restart.
But the air domain is heated very quickly and it has not a big impact on the final result when initializing the whole mesh instead of initializing only the solid domain by chance.

I use a max Fourier number of 10000, I have around 0.5 s time step, I do a transient simulation of 8000 physical seconds, and the simulation takes hours. I use adaptative time step option, but I have a constant time step during the calculation. Is there a way to have smaller time steps when the temperature change quickly and larger time step when the temperature is close to the stationary state?

For the moment my first result with the coarse mesh is quite far for the result expected. I will try different wall law, turbulence model etc, but I suffer of a lack of post processing tools.

What is the simplest solution to compute a spatial average temperature for the solid domain on each time step ? For the moment I use integration of paraview for each time step. I see that there is some user-function in example but it is mainly for field time average.
The last step would be to add HTC transfer coefficient user-function on the fluid/solid interface but I think it is far too complicated for me.

Best regards

Julien
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by Yvan Fournier »

Hello,

For spatial averages, you can simply compute a sum + reduction on the solid zone in a user-defined functions such as cs_user_extra_operations.c. There are quite a few examples in cs_user_boundary_conditions.c (See Doxygen documentation).

If you seek a "non-programmatic" way of computing this, you can use ParaView, but writing/reading the whole postprocessing output at each time step will be very costly.

Best regards,

Yvan
jgd23
Posts: 141
Joined: Mon Jun 06, 2016 10:00 am

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by jgd23 »

Hello Yvan,

Thank you for your answer. I will look for user-functions to do averages on volumes.

Could you answer my question about adaptative time steps please?

Julien
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by Yvan Fournier »

Hello,

It is surprising that the adaptive time step does not change at all. Though the adaptation is done based mostly on the CFL, so if the computation uses a frozen field, it may be ignored. I think the Fourier number also intervenes, but am not sure how everything is combined (this is done in src/base/dttvar.f90, but I have not looked into it in a while).

Does the fixed time step match the minimum or maximum time step for you ? In this case you might try to change the minimum/maximum values. Otherwise, it may be interesting to use a fixed time step, as you can probably use a higher value, especially in a frozen velocity case (where stability issues should be less of a problem).

Best regards,

Yvan
jgd23
Posts: 141
Joined: Mon Jun 06, 2016 10:00 am

Re: Conjugate heat transfer of simple geometries - comparison with exp data

Post by jgd23 »

Hello,

I found an example very close to my case to calculate the average scalar quantity on a mesh.

Code: Select all

void
cs_user_extra_operations(cs_domain_t     *domain)
{
  /* Variables declaration */

  /* Handle to the moy.dat file that will be filled with Tav;
   declared as static so as to keep its value between calls. */
  static FILE *file = NULL;

  /* Get pointers to the mesh and mesh quantities structures */
  const cs_mesh_t *m= cs_glob_mesh;
    const cs_mesh_quantities_t *fvq = cs_glob_mesh_quantities;

  /* Number of cells */
  const int n_cells = m->n_cells;

  /* Cell volumes */
  const cs_real_t *cell_vol = fvq->cell_vol;

  /* Get the temperature field */
  const cs_field_t *temp = cs_field_by_name_try("temperature");

  /* Total domain volume */
  cs_real_t voltot = fvq->tot_vol;

  /* Temp * volumes sum and Tavg */
  cs_real_t temptot =0., Tavg =0.;

  /* Compute the sum T*vol */
  for (int ii = 0 ; ii < n_cells ; ii++)
    temptot += temp->val[ii]*cell_vol[ii];

  /* Parallel sums */
  cs_parall_sum(1, CS_REAL_TYPE, &temptot);

  /* Compute Tavg */
  Tavg = temptot / voltot;

  /* Open the file moy.dat at the first iteration
     and write the first comment line only on the
     first processor (0 in parallel, -1 in serial) */
  if (cs_glob_time_step->nt_cur == 1 && cs_glob_rank_id <= 0) {
    file = fopen("moy.dat", "a");
    fprintf(file, "#Time (s)   Average Temperature (C) \n");
  }

/* Print the average temperature at the current time step
   on the first processor only */
  if (cs_glob_rank_id <= 0)
    fprintf(file, "%.6f  %.6f\n",cs_glob_time_step->t_cur, Tavg);

/* Close the file moy.dat at the last iteration
   on the first processor only */
  if (cs_glob_time_step->nt_cur == cs_glob_time_step->nt_max
   && cs_glob_rank_id <= 0)
    fclose(file);
Now I need to access to the local domain mesh called "solid"
I try

Code: Select all

const cs_mesh_t *m= cs_volume_zone_by_name("solid");
But it is for volume not for mesh.

On doxygen I don't find in the mesh selection criteria how to call a specific domain mesh.
I think it is related with
cs_user_zones (void)

but I don't find example showing the syntax etc...

If I succeed to declare that the average computation is only done on the "solid" domain, I think that I can stay with the rest of this code. Variable "tot_vol" will be working only on the "solid domain" or on the whole geometry?

Why this line exists

Code: Select all

/* Print the average temperature at the current time step
   on the first processor only */
  if (cs_glob_rank_id <= 0)
    fprintf(file, "%.6f  %.6f\n",cs_glob_time_step->t_cur, Tavg);
?
If the domain "solid" is calculated on several processor it will give a wrong average value?
The line works only for specific case ?

Could you help me a bit with this please ? Thank you

Best regards
Post Reply