Page 1 of 1

input parameters depending results

Posted: Sat Aug 13, 2016 12:05 am
by jgd23
hello,

Is it possible to give some input parameters (for example an input temperature imposed on an inlet) which are depending of measurements (for example the temperature average of a domain). In Comsol, it's a really helpfull feature which permits to gain lot of time. Adding an equation to adjust an input variable to have the desired flux or temp on a spcecific boundary or domain.

Best regards

Julien

Re: input parameters depending results

Posted: Sat Aug 13, 2016 1:17 am
by Yvan Fournier
Hello,

Yes, it is possible, but for advanced settings, you will need to edit user subroutines, such as cs_user_boundary_conditions.f90. You can check the Doxygen documentation for examples.

Regards,

Yvan

Re: input parameters depending results

Posted: Sat Aug 13, 2016 1:14 pm
by jgd23
Hello,

That's a good news but it seems to be quite difficult to do for me. I have to use results from other parts on the geometry. Maybe someone can help me to start... or with a more explicit example.

Best regards

Julien

Re: input parameters depending results

Posted: Sat Aug 13, 2016 2:32 pm
by Yvan Fournier
Hello,

Spatially averaged, or sampled ? The best examples to point to depend on this.

Regards,

Yvan

Re: input parameters depending results

Posted: Sat Aug 13, 2016 7:41 pm
by jgd23
Hello,

Yes, spatially average. But the better case for my study should be the average temperature on a solid domain where the temperature is computed with syrthes.

Best regards

Julien

Re: input parameters depending results

Posted: Mon Aug 15, 2016 2:47 pm
by Yvan Fournier
Hello,

I believe you can use Syrthes user subroutines to compute the average temperature, but there is no simple way to exchange that info with Code_Saturne (this would be much easier with Code_Saturne/Code_Saturne coupling, which should be available for thermal cases in version 5.0.

What you want to do would be relatively easy to add by modifying non-user subroutines, but for now, I don't see a simple way to do it only with user subroutines (an modifying the code itself depends on how comfortable with programming).

I'll update this if I have a better idea.

Regards,

Yvan

Re: input parameters depending results

Posted: Mon Aug 15, 2016 5:16 pm
by jgd23
hello,

I have not really a large experience as programmer.
I think that it's possible for my problem to adjust the inlet temperature with "only" the heat flux measured on a desired surface (surface of the solid in contact with the fluid domain).
So maybe, it's possible to make a CS/CS coupling in this way with user subroutine?

Best regards

Julien

Re: input parameters depending results

Posted: Mon Aug 15, 2016 7:49 pm
by Yvan Fournier
Hello,

You can obtain the flux for the previous time step quite easily, but the one for the current time step is computed after the user boundary condition definitions, so that would be more difficult to use.

For the previous time step, when defining your inlet conditions (in cs_user_boundary_conditions.f90), you can first do a selection of the faces used for Syrthes coupling (using the matching criteria), then call post_boundary_thermal_flux. Do not forget to add "use post_util" near the other "use" statements at near the beginning of the file.

So basically, if you have:

Code: Select all

integer          ilelt, nlelt
double precision tflux

integer, allocatable, dimension(:) :: lstelt
double precision, allocatable, dimension(:) :: bflux

allocate(lstelt(nfabor))
allocate(bflux(nfabor))

call getfbr("selection_criteria", nlelt, lstelt)
call post_util(nlelt, lstelt, bflux)

tflux = 0
do ilelt = 1, nlelet
  tflux = tflux + bflux(ilelt)
enddo

if (irangp.ge.0) then
  call parsom(tflux)
endif
Replacing with your own selection criteria, you will have the total flux from the previous time step in tflux. Using that, you can adapt the rest of the examples fond for boundary conditions in the Doxygen documentation.

Regards,

Yvan