Several uniform heat source

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
fomeh

Several uniform heat source

Post by fomeh »

Hi guys,

I'm trying to impose several uniform space dependent volumetric heat source in a domain. A good exapmle has been given in tutorials(cs user_source_terms: subroutine ustssc) for just one uniform source:

Code: Select all

pwatt = 1000000.d0

! calculation of volf

volf  = 0.d0
CALL GETCEL('X > 0.0',NLELT,LSTELT)

do ilelt = 1, nlelt
  iel = lstelt(ilelt)
  volf = volf + volume(iel)
enddo

do ilelt = 1, nlelt
  iel = lstelt(ilelt)
! No implicit source term
  crvimp(iel) = 0.d0
! Explicit source term
  crvexp(iel) = volume(iel)*pwatt/volf
enddo

!--------
! Formats
!--------

 1000 format(' User source terms for variable ',A8,/)

!----
! End
!----

! Deallocate the temporary array
deallocate(lstelt)

return
end subroutine ustssc
It works well, no trouble. Now, how can i modify it if I have several pwatt not just one? I've tried to put them in seperate subroutines with different name but it does not work; no compilation error but seems that it is not called if I modify the statement (i.e. ustssc).

I appreciate any comment
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Several uniform heat source

Post by Yvan Fournier »

Hello,

You can simply use a different selection criteria for getcel (there is absolutely no requirement that selected cells be contiguous).

So for example, getcel("box[x1,y1,z1,x2,y2,z3] or box[x3,y3,z3,x4,y4,z4]", nltcel, lstcel)

If you have volume groups, use thos (for example "S1 or S2" to select cells from groups named S1 and S2).

Regards,

Yvan
fomeh

Re: Several uniform heat source

Post by fomeh »

Hello Yvan

Do you mean the soubroutine should call GETCEL for each segment related to the source terms and that should be repeated from just one cs_user_source_terms.f90? Then how should I modify:

Code: Select all

crvexp(iel) = volume(iel)*pwatt/volf
Could you please explain more :roll:
Thanks again
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Several uniform heat source

Post by Yvan Fournier »

Hello,

you must build only one list in one cs_user_source_terms.f90 call.

You may build it using multiple calls to getcell and appending sublists to a more complete list, but it is simpler to adjust the cell criteria to obtain all segments in one call.

So if your source term is uniform, a single getcell is better. If your source term is dependent on zones, then building the list by pieces may be better, so you then assign the correct values for each list.

If your source terms do not require a too complex formula, I recommend defining the thermal source terms with the GUI. It allows defining thermal source terms by zones, while you need to mange zones yourself with a user subroutine.

Regards,

Yvan
fomeh

Re: Several uniform heat source

Post by fomeh »

Yvan I've already tried to impose these source terms by using the GUI but it does'nt work even for one zone selection. For any intensity of thermal source, the temperature remains equal to the initial value! Could you please take a look at my xml file?
Thanks alot
Attachments
params.xml
(10.66 KiB) Downloaded 373 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Several uniform heat source

Post by Yvan Fournier »

Hello,

Which version of the code are you using ? There was a bug due to which the thermal source terms defined by the GUI were ignored, but it seems to have been fixed on all branches last December (so the bug may be in 3.02 but should be fixed in 3.0.3 or at worst 3.0.4, although it seems the info on this fix is missing in the NEWS file).

Regards,

Yvan
fomeh

Re: Several uniform heat source

Post by fomeh »

It is 3.0.0 so i have to reinstall. Does the V. 2 have the same bug? I tried with V. 2 but results were same.

Can you please tell me what are the units for S: thermal source term and dS: thermal source term derviative in the GUI?
kunalck
Posts: 16
Joined: Fri Sep 21, 2018 2:06 pm

Re: Several uniform heat source

Post by kunalck »

Hello Yvan,

I am trying to impose a volumetric heat source thoughout the domain(not on boundary cells- they have different BCs) in an non regular geometry. I am trying to use following

Code: Select all

do iel=1,ncel
crvexp(iel) = volume(iel)*pwatt/voltf;
enddo
for imposing the heat source term. Do these 'ncel' also select cells on the boundaries or only the cells within the domain(and not boundary cells) are selected ??
As my domain has an arc of a circle instead of other two walls in a regular rectangular geometry. And geometrically it is a bit difficult to define them for cell selection.
Thanks in advance.

Regards
Kunal

Yvan Fournier wrote: Wed Jul 23, 2014 11:18 pm Hello,

you must build only one list in one cs_user_source_terms.f90 call.

You may build it using multiple calls to getcell and appending sublists to a more complete list, but it is simpler to adjust the cell criteria to obtain all segments in one call.

So if your source term is uniform, a single getcell is better. If your source term is dependent on zones, then building the list by pieces may be better, so you then assign the correct values for each list.

If your source terms do not require a too complex formula, I recommend defining the thermal source terms with the GUI. It allows defining thermal source terms by zones, while you need to mange zones yourself with a user subroutine.

Regards,

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

Re: Several uniform heat source

Post by Yvan Fournier »

Hello,

If you look on all cells those adjacent to the boundary will be selected also.

Note that selection criteria can also include cylinders ou spheres, though using groups is always better when available. (see documentation) but if cells adjacent to the boundary have a special role In your case you can still cancel the contribution on them. If you look on boundary faces, ifabor(iface) gives you the I'd of the adjacent cell.

Hope I understood your question correctly (a diagram would help otherwise if this is a complex case).

Best regards,

Yvan
kunalck
Posts: 16
Joined: Fri Sep 21, 2018 2:06 pm

Re: Several uniform heat source

Post by kunalck »

Hello Yvan,

Thank you for your reply. Currently I am using following code which adds heat source in each cell and then removes from the boundary cells. But I am not entirely sure if this the correct way of writing it. Boundary faces have colors 1to5.

Code: Select all

do iel=1,ncel
crvexp(iel) = volume(iel)*pwatt/voltf;
enddo
allocate (lstfac(nfac))
call getfac('1 or 2 or 3 or 4 or 5',nlfac,lstfac)
 do iel = 1, nlfac
    ifac = lstfac(iel);
    iel2 = ifabor(ifac);
      crvexp(iel2) = 0.0d0;
 enddo
deallocate(lstfac)
geom.png
(6.74 KiB) Not downloaded yet
Post Reply