CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] GroovyBC with power input (heat flux) (https://www.cfd-online.com/Forums/openfoam-community-contributions/149819-groovybc-power-input-heat-flux.html)

Tobi March 9, 2015 11:08

GroovyBC with power input (heat flux)
 
Hi all,

I did not get the point to build a heat flux bc with groovy.
Why I use groovy is due to the fact that I also have to use some gaussian probability distribution.

At least I used this summary: http://www.modlab.lv/docs/2011/OpenF...Vilums_pdf.pdf

So what we get is the following situation:

T_f = f \cdot valueFraction + (1-f) \cdot (T_{centre} + gradExpr \cdot \delta)

f is the fractionExpression.

Now I want to use the gradient expression to evaluate the temperature at the face. We get the following expression:

\nabla T = \frac{q}{A} \cdot \frac{1}{kappa}

This is exactly the same expression like in the turbulentHeatFluxTemperature BoundaryCondition.

Now I expect, that the fractionExpression is zero. Therefore only the second term in the first eqn. is valid and we can write:

T_f = T_{centre} + gradExpr \cdot \delta

This is equal to:

\frac{T_f - T_{centre}}{\delta} = gradExpr

and that is equal to:

\nabla T = \frac{q}{A} \cdot \frac{1}{kappa}

In groovyBC I used the following code:
Code:

    top
    {

        type            groovyBC;
        variables      "Kappa=160;Q=10000;g=Q/sum(mag(Sf()))/Kappa;";
        fractionExpression "0";
        gradientExpression "g";
        value          uniform 300;
    }

If I run the simulation I will get a Temperature at the faces equal to zero and I do not know why? I think I made a stupid mistake. Any suggestion is appreciated.

Thanks in advance,

zfaraday March 9, 2015 12:31

Hi Tobi!

Quote:

Originally Posted by Tobi (Post 535360)
In groovyBC I used the following code:
Code:

    top
    {

        type            groovyBC;
        variables      "Kappa=160;Q=10000;g=Q/sum(mag(Sf()))/Kappa;";
        fractionExpression "0";
        gradientExpression "g";
        value          uniform 300;
    }


I haven't checked it much deeply, but with a slight glance I don't know if it's correct your definition of g. Maybe trying with this other g could solve it:
Code:

g=Q/mag(Sf())/Kappa
Let us know if it does the trick! ;)

Btw, is the same mag(Sf()) than area()? Or does area() take the sign of normal direction into account?

Best regards,

Alex

Tobi March 9, 2015 14:43

Hi Alex,

I need the whole area of the surface (not only one face). If I use yours, then the heatflux will increase extreamly (dividing by a very small number).

That is not the problem.

zfaraday March 9, 2015 15:03

Quote:

Originally Posted by Tobi (Post 535396)
Hi Alex,

I need the whole area of the surface (not only one face). If I use yours, then the heatflux will increase extreamly (dividing by a very small number).

That is not the problem.

Yes, you are right Tobi, sorry, I wrote that after a quick glance to the formulation without checking the calculation on paper. I got confused because recently I have been using groovyBC aswell but in my case it was for convection heat transfer not fixed power and I worked with heat fluxes instead of total heat. That's why understood wrong your formulation, I didn't remember any sum(...) below the fraction. After checking deeper your formulation, it seems to be ok... Have you managed to solve the problem with temperatures?

Tobi March 10, 2015 03:57

Hi,

today it is working! I don't know what was the problem. The only thing that I changed today was to set the fractionExpression to zero but if I check the first post, I already did this yesterday. Don't know but its working proper now :)


To your question ... area() - never used this option in groovy. Is it really a groovyBC function? It is definitly not the same as above.

Kanarya January 12, 2016 05:49

Dear Tobi,

I would like to use groovyBC in order to apply constant 400 kW/m^2 heat flux at the wall but I could not find how?
can you help me?
I am using OF version 2.3.1
Thanks!

Quote:

Originally Posted by Tobi (Post 535483)
Hi,

today it is working! I don't know what was the problem. The only thing that I changed today was to set the fractionExpression to zero but if I check the first post, I already did this yesterday. Don't know but its working proper now :)


To your question ... area() - never used this option in groovy. Is it really a groovyBC function? It is definitly not the same as above.


Tobi January 12, 2016 06:17

Hi,

I think you can use "turbulentlHeatTransferTemperature" for that. You can apply the flux [W/m^2]. There is no need for groovy. If you want to use groovy you have to derive the equation yourself / or just check the pdf in the first link. It shoud be sufficient.

Kanarya January 12, 2016 07:07

thanks for the quick answer...yes you are right!I thought so as well but I have laminar flow so I do not have "alphaEff" so it gives me a problem
Code:

--> FOAM FATAL ERROR:

    request for volScalarField alphaEff from objectRegistry region0 failed
    available objects of type volScalarField are

24
(
alpha.water_0
cp
alpha.vapour
interfaceProperties:K
pSat
alpha.water
mCond
kappa
rho
mVap
p_rgh
nu
gh
nu1
((hEvap*(mCond+mVap))|T)
IF
p
rho_0
nu2
T
rhoCp_0
(-IF*SLarge)
rhoCp
((IF*SLarge)*TSat)
)


    From function objectRegistry::lookupObject<Type>(const word&) const
    in file /usr/local/OpenFOAM//OpenFOAM-2.3.1/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 198.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) in "/usr/local/OpenFOAM//OpenFOAM-2.3.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::error::abort() in "/usr/local/OpenFOAM//OpenFOAM-2.3.1/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const& Foam::objectRegistry::lookupObject<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >(Foam::word const&) const in "/home/links/rek209/OpenFOAM/rek209-2.3.1/platforms/linux64GccDPOpt/lib/libphaseChangeTwoPhaseMixturesInterEvapCondPhaseChangeFoam.so"
#3  Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs() in "/usr/local/OpenFOAM//OpenFOAM-2.3.1/platforms/linux64GccDPOpt/lib/libincompressibleTurbulenceModel.so"
#4  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::updateCoeffs() at /usr/local/OpenFOAM//OpenFOAM-2.3.1/src/OpenFOAM/lnInclude/PtrListI.H:36
#5  Foam::fvMatrix<double>::fvMatrix(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensionSet const&) at /usr/local/OpenFOAM//OpenFOAM-2.3.1/src/finiteVolume/lnInclude/fvMatrix.C:325
#6  Foam::tmp<Foam::fvMatrix<double> > Foam::fvm::Sp<double>(Foam::DimensionedField<double, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at /usr/local/OpenFOAM//OpenFOAM-2.3.1/src/OpenFOAM/lnInclude/tmpI.H:191
#7  Foam::tmp<Foam::fvMatrix<double> > Foam::fvm::Sp<double>(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) at /usr/local/OpenFOAM//OpenFOAM-2.3.1/src/OpenFOAM/lnInclude/tmpI.H:176
#8 
 at /scratch/rkahraman/evapCond/interEvapCondPhaseChangeFoam_allfiles/interExCondPhaseChangeFoam/TEqn.H:36
#9  __libc_start_main in "/lib64/libc.so.6"
#10 
 in "/home/links/rek209/OpenFOAM/rek209-2.3.1/platforms/linux64GccDPOpt/bin/interExCondPhaseChangeFoam"
Aborted

Quote:

Originally Posted by Tobi (Post 580608)
Hi,

I think you can use "wallHeatTransfer" for that. You apply Tinf and alpha there. There is no need for groovy. If you want to use groovy you have to derive the equation that have to be implemented in groovy yourself / or just check the pdf in the first link.

Thanks for your help

Tobi January 12, 2016 07:15

Hi,

it seems that its your own solver. Do you have a field implemented that correspond to "thermal diffusivity"? If yes then use that, otherwise implement it to your solver or change the BC or if you want, use groovy.

Kanarya January 12, 2016 09:37

Thanks again...the problem is I know only the thermal conductivity and heat flux, so I can not implement groovyBC...do you have any idea how i can build the groovyBC in order to have fix heat flux?

BEST!

Tobi January 12, 2016 10:04

Hi,

I don't know what your application is for and what you actually want to do but if I understand it correct you can use the groovy in the first post:


All times are GMT -4. The time now is 21:14.