Non-diffusion volume heat source settings

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Steven Tang
Posts: 3
Joined: Thu May 12, 2022 6:38 am

Non-diffusion volume heat source settings

Post by Steven Tang »

Dear all,

I am a newbie to code-saturne,recently,I'm learning how to set the non-diffusion volume heat source.

For example, I define a temp source terms zone(1<x<2,1<z<2) on the GUI page, and name it "cooler". In the "cs_user_source_terms-base .c" file, I did the following . However,this volumetric heat source is diffuse,which could affect the temperature of the area around it. I want this volume heat source to remain in the area I defined, and it will not affect the temperature of the surrounding area. Only when the fluid passes through the area, the effect of the volume heat source will be reflected, which will change the fluid temperature passing through the area.
Can anyone give me some code modification suggestions if it is convenient?
Besides,If it is convenient, can you tell me how to call the current time step, such as using "ttcabs" in Fortran, and how to express it in C language.
Thank you very much for any ideas on this matter
Kind regards
Steven

-----------------------------------------------

#include "cs_defs.h"
#include <assert.h>
#include <math.h>
#include <ple_coupling.h>
#include "cs_headers.h"
BEGIN_C_DECLS
void
cs_user_source_terms(cs_domain_t *domain,
int f_id,
cs_real_t *st_exp,
cs_real_t *st_imp)
{
CS_NO_WARN_IF_UNUSED(domain);
const cs_field_t *f = cs_field_by_id(f_id);
const cs_lnum_t n_cells = cs_glob_mesh->n_cells;
const cs_real_t *cell_f_vol = cs_glob_mesh_quantities->cell_vol;
int var_f_id = cs_field_get_key_int(f, cs_field_key_id("first_moment_id"));
const cs_real_t *cpro_rom = CS_F_(rho)->val;
if (f == CS_F_(t)) {
const cs_var_cal_opt_t *var_cal_opt
= cs_field_get_key_struct_const_ptr(f,
cs_field_key_id("var_cal_opt"));
if (var_cal_opt->iwarni >= 1)
bft_printf(" User source terms for variable %s\n",
cs_field_get_label(f));

/*************************************************************************************/
// main code here!!!!!!!!!!!!!!!!!!!!!!!!

const cs_zone_t *z1 = cs_volume_zone_by_name_try("cooler");
if (z1 != NULL) {

for (cs_lnum_t i = 0; i < z1->n_elts; i++) {
cs_lnum_t c_id = z1->elt_ids;
st_imp[c_id] = -100;
}
}
/************************************************************************************/
}
}

END_C_DECLS
Yvan Fournier
Posts: 3674
Joined: Mon Feb 20, 2012 3:25 pm

Re: Non-diffusion volume heat source settings

Post by Yvan Fournier »

Hello,

There is no option to cut diffusion for the source term only. So in your case, you would need to set the diffusion (and the turbulent diffusion) to zero on one layer of cells just upstream of the source term zone (doing it at the faces would be better, but I do not think thee is a user option for that, so it would require modifying the code).

Laminar diffusivity may be defined using either the GUI or user-defined functions, but to change the turbulent viscosity, you need to use a user-defined function.

Best regards,

Yvan
Post Reply