CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Thermal conductivity as function of temperature (http://www.cfd-online.com/Forums/openfoam-programming-development/107945-thermal-conductivity-function-temperature.html)

magazoni October 10, 2012 06:32

Thermal conductivity as function of temperature
 
Hi everyone,

I'm trying to make a test with the solver laplacianFoam making the thermal conductivity as function of temperature. I'm doing something like that:

fvScalarMatrix Teqn
(
fvm::ddt(rho, T)
- fvm::laplacian(k_T(T)/Cp, T)
);
Teqn.solve();
}

My idea is create a function to calculate the thermal conductivity:

dimensionedScalar k_T(volScalarField T)
{
dimensionedScalar k1
(
"k1",
dimensionSet(1,1,-3,-2,0,0,0),
-0.0691734413
);
dimensionedScalar k2
(
"k2",
dimensionSet(1,1,-3,-1,0,0,0),
421.0792245378
);
volScalarField k;
k=k1*T+k2;
return k;
}

But it's not working. How can I do it using a function?

Thanks,
Best regards,
Felipe Magazoni

Chrisi1984 October 10, 2012 07:42

Hi Felipe,

the following code should give you an idea how to do it:

Quote:

{
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix tEqn
(
-fvm::laplacian(K, T)
);
tEqn.relax();
eqnResidual = tEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);

}

Info<< "Min/max T:" << min(T).value() << ' '
<< max(T).value() << endl;

//////////////////////////////////////

forAll(solidRegions[i].cellZones(), zoneI)
{
const cellZone& cz = solidRegions[i].cellZones()[zoneI];
const labelList& cells = cz;

if (cz.name() == "s-oc")
{
forAll(cells, iCells)
{
const label cellId = cells[iCells];
const scalar& cellT = T[cellId];

cp[cellId] = 380.68 + cellT * (0.35536 - 0.00012713 * cellT);
K[cellId] = 9.6995954 + cellT * (0.017429246 - 2.0551036e-06 * cellT);
rho[cellId] = 7920;
}
}

}


/////////////////////////////////////

}
It is an example for a steady solver, but it should not be that difficult to modify it for your time depending equation.

Don't forget to define your variables in the "createFields" file.

Kind regards

Chrisi

nakor December 31, 2012 10:19

hello Chrisi,
I am looking to implement something a bit similar, I would like to have a value 'a' for my thermal conductivity if the temperature is under a certain value, and a value 'b' for my thermal conductivity if the temperature is above the value.
Something like,

Code:

if (cz.name() == "s-oc")
{
forAll(cells, iCells)
{
const label cellId = cells[iCells];
const scalar& cellT = T[cellId];

cp[cellId] = 380.68 + cellT * (0.35536 - 0.00012713 * cellT);

if (cellT<273.15)
{
K[cellId] = 10;
}
else
{
K[cellId] = 100;
}

rho[cellId] = 7920;
}
}

is that possible ? I never used those kind of thermal dependent constant in my code before.

Thanks,

Chrisi1984 January 5, 2013 11:54

Hallo Nakor,

at the minute for me it seems that your code should work.

Kind regards,

Chrisi

mkraposhin January 6, 2013 12:52

I can hint a bit more elegant solution:
{
dimensionedScalar k1 (dict.lookup("k1"));
dimensionedScalar k2 (dict.lookup("k2"));
volScalarField k = k1*T + k2;
volScalarField DT = k / Cp1;

fvScalarMatrix Teqn
(
fvm::ddt(rho, T)
- fvm::laplacian(DT, T)
);
Teqn.solve();
}


All times are GMT -4. The time now is 22:23.