Fan definition with cs_ventil

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

Fan definition with cs_ventil

Post by Martin Isack »

Hello,

I would like to define a fan. Unfortunately I have no idea how to use the Fortran API of cs_ventil.h to define a source term in ustsns. Does someone have an example or can help me how to set up a fan?

Regards,
Martin
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fan definition with cs_ventil

Post by Yvan Fournier »

Hello,

I recently came upon a post relative to this in our old Forum (reproduced here) when checking the result of the web site migration, but the content is not obvious by the title (and I do not rember which post is relative to this).

I also gave a few (less detailed) recommendations recently in this thread:http://code-saturne.org/forum/viewtopic.php?f=2&t=1040.

I do not have any other suggestion for now (we need to add examples for this in standard user subroutines).

Best regards,

Yvan
Martin Isack

Re: Fan definition with cs_ventil

Post by Martin Isack »

Hello,

I also found a post from David:
http://code-saturne.org/forum/viewtopic ... ntil#p4297
- define a fan -> defvtl (to be done only once)
- initialize fans -> inivtl (to be done only once)
- get the number of fans -> tstvtl
- compute the source term associated -> tsvvtl
Where do I have to insert this code? My guess is in the subroutine ustsns after the comment block which starts with

Code: Select all

! 2. Example of arbitrary source term for component u:
The first subroutine defvtl is described as follows:

Code: Select all

 * SUBROUTINE DEFVTL
 * *****************
 *
 * INTEGER          DIMMOD     : <-- : Fan model dimension:
 *                             :     : 1: constant_f; 2: force_profile;
 *                             :     : 3: force_profile + tangential couple
 * INTEGER          DIMVTL     : <-- : Fan dimension:
 *                             :     : 2: pseudo-2D (extruded mesh)
 *                             :     : 3: 3D (standard)
 * DOUBLE PRECISION XYZVT1(3)  : <-- : Coo. of the axis point in upstream face
 * DOUBLE PRECISION XYZVT2(3)  : <-- : Coo. of the axis point in downstream face
 * DOUBLE PRECISION RVVT       : <-- : Fan radius
 * DOUBLE PRECISION RPVT       : <-- : Blades radius
 * DOUBLE PRECISION RMVT       : <-- : Hub radius
 * DOUBLE PRECISION CCARAC(3)  : <-- : Coefficients of degre 0, 1 and 2
 *                             :     : of the characteristic curve
 * DOUBLE PRECISION TAUVT      : <-- : Fan axial couple
What does

Code: Select all

Fan axial couple
mean?

Would a proper call of this function look like this:
defvtl(2, 3, (/1, 1, 1/), (/1, 2, 1/), .5, .4, .1, 0, tauvt) ?

Regards,
Martin
Martin Isack

Re: Fan definition with cs_ventil

Post by Martin Isack »

Hello,

I just tried the following:

Code: Select all

call defvtl(2, 3, (/ 1., 1., 1. /), (/ 1., 2., 1. /), .5, .4, 1, (/ 0, 0, 0 /), 1.)

call inivtl()

if (ivar.eq.iu) then

  do iel = 1, ncel
     call tstvtl(nbrvtl)
     call tsvvtl(3, crvexp(iel))
  enddo

endif

if (ivar.eq.iv) then

  do iel = 1, ncel
     call tstvtl(nbrvtl)
     call tsvvtl(2, crvexp(iel))
  enddo

endif

if (ivar.eq.iw) then

  do iel = 1, ncel
     call tstvtl(nbrvtl)
     call tsvvtl(3, crvexp(iel))
  enddo
endif
It doesn`t raise an error, but it also doesn't have an effect on the simulation. What do I need the fan number (nbrvtl) for?

Regards,
Martin
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fan definition with cs_ventil

Post by Yvan Fournier »

Hello,

Could you print the values of crvexp(iel) after calling tsvvtl ?

The values my simply be too small.

A more advanced test would be to write similar loops to define a postprocessing variable in suvpst, to postprocess the applied source term.

Also, be careful to add a test on the call number (using a static integer for example) so as to define fans only once, but apply the source term at each time step.

Best regards,

Yvan
Martin Isack

Re: Fan definition with cs_ventil

Post by Martin Isack »

Hello,

I slowly understand how to use the ventil functions.
I define and initialize the fan in cs_user_initialization.

Code: Select all

call defvtl(1, 3, (/ 1., 0., 1. /), (/ 1., 2., 1. /), 1., .9, .1, (/ 1, 1, 1 /), 1.)
call inivtl()
call numvtl(fannbr)
print *, fannbr
numvtl outputs the assigned fan number for every single cell (0 if outside the fan). The mesh is a cube of the size 2x2x2. With the above fan definition nearly the whole domain should be assigned to this fan, but the output of numvtl is 0 for all cells.
I also have still no idea what the last parameter Fan axial couple of the fan definition means.

Regards,
Martin
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: Fan definition with cs_ventil

Post by Yvan Fournier »

Hello,

I am not sure passing arrays as you do works. We do not use this syntax, so if you have used it elsewhere and it works for you elswhere, fine (and you have a more elegant syntax), but I would expect this syntax to imply "true" Fortran 90 arrays, such as that which you would obtain with the dimension(:) declaration (and carries metadata/size info), while the defvtl subroutine has no explicit interface, so it expects C/Fortran77 type arrays, such as those you obtain with
dimension(*) (which is a pure C pointer).

I did not try this under a debugger, but unless you are sure it works in other parts of the code, I would try the following, less elegant, but more basic syntax:

Code: Select all

double precision cu(3), cd(3), fcar(3)

cu(1) = 1.d0
cu(2) = 0.d0
cu(3) = 1.d0
cd(1) = 1.d0
cd(2) = 2.d0
cd(3) = 1.d0
fcar(1) = 1.d0
fcar(2) = 1.d0
fcar(3) = 1.d0

call defvtl(1, 3, cu, cd, 1., .9, .1, fcar, 1.)
call inivtl()
Best regards

Yvan
Martin Isack

Re: Fan definition with cs_ventil

Post by Martin Isack »

Hello,

I set up a new case with the same mesh and only created a cs_user_initialibation.f90. I tried your syntax, but it doesn't change anything. There are still no cells associated to the fan. But tstvtl, which gives the number of fans, tells me that there is 1 fan. What could be the reason, that inivtl doesn't find any associated cells? I checked my mesh many times.

Code: Select all

 Mesh coordinates:               minimum    and maximum
                       X :  0.0000000e+00  2.0000000e+00
                       Y :  0.0000000e+00  2.0000000e+00
                       Z :  0.0000000e+00  2.0000000e+00
 Mesh
     Number of cells:          8000
     Number of interior faces: 22800
     Number of boundary faces: 2400
     Number of vertices:       9261
 --- Information on the volumes
       Minimum control volume      =  1.0000000e-03
       Maximum control volume      =  1.0000000e-03
       Total volume for the domain =  8.0000000e+00
Regards

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

Re: Fan definition with cs_ventil

Post by Yvan Fournier »

Hello,

I don't know what is causing this. I'll try to run a test early next week.

What version are you using (this part of the code has not changed recently, but if data is overwritten for example, I'd rather test on a similar version).

Best regards,

Yvan
Martin Isack

Re: Fan definition with cs_ventil

Post by Martin Isack »

Hello,

I am using the latest version 2.2. Thank you very much for your help!

Kind regards

Martin
Post Reply