CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

How to control the heat source according to the temperature of a point?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 13, 2022, 09:49
Default How to control the heat source according to the temperature of a point?
  #1
New Member
 
chenfuqiang
Join Date: Nov 2022
Posts: 3
Rep Power: 3
elelel is on a distinguished road
Dear community,
I want to get the temperature ''Tpoint'' at a point in the geometry. When Tpoint ≥150℃, set the heat source to 0, and when Tpoint < 150℃, set the heat source to a value, like 100.Can I get the ''Tpoint'' using the probe? Can I add an if statement about Tpoint before the energy equation of the solver?
Could you give me some tips to achieve this?
Thank you in advance.
elelel is offline   Reply With Quote

Old   December 19, 2022, 10:18
Default
  #2
Senior Member
 
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 355
Rep Power: 8
geth03 is on a distinguished road
fvOptions or fvModels should do the trick here.
geth03 is offline   Reply With Quote

Old   January 3, 2023, 04:15
Default control the temperature every 0.5s
  #3
New Member
 
chenfuqiang
Join Date: Nov 2022
Posts: 3
Rep Power: 3
elelel is on a distinguished road
Hi geth03,
Thank you very much for your reply. I modified chtMultiRegionFoam/solid/solveSolid.H.
Please find it below:
Code:
{
    while (pimple.correctNonOrthogonal())
    {
//control point
fvMesh& mesh = solidRegions[i];
point position = point(0.0425,0.021,0.135);
label mycell = mesh.findCell(position);
const Foam::volScalarField& T = mesh.lookupObject<Foam::volScalarField>("T");
scalar Tcell = T[mycell];
reduce(Tcell, maxOp<scalar>());
//
if (Tcell < 340)
{
        fvScalarMatrix hEqn
        (
            fvm::ddt(betav*rho, h)
          - (
                thermo.isotropic()
              ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
              : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
            ) + poy    //poy is volScalarField.
          ==
            fvOptions(rho, h)
        );      
}
else
{
        fvScalarMatrix hEqn
        (
            fvm::ddt(betav*rho, h)
          - (
                thermo.isotropic()
              ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
              : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
            ) 
          ==
            fvOptions(rho, h)
        );     
}
    }
}

hEqn.relax();
fvOptions.constrain(hEqn);
hEqn.solve();
fvOptions.correct(h);
thermo.correct();

Info<< "Min/max T:" << min(thermo.T()).value() << ' '
    << max(thermo.T()).value() << endl;
And I have another problem. In the controlDict file , the deltaT is 0.01. So the above code judges every 0.01s. It is too frequent. I want to control the temperature every 0.5s.
I use:
Code:
if (runTime.value()==0 or fmod(runTime.value(), 0.5) ==0)//Multiple of 0.5
{the above code}
but this only run hEqn at 0s,0.5s,1s,1.5s... ...
I dont know how to judge every 0.5s instead of judge by the deltaT.

Thank you in advance!
elelel is offline   Reply With Quote

Old   January 3, 2023, 09:41
Default Has solved
  #4
New Member
 
chenfuqiang
Join Date: Nov 2022
Posts: 3
Rep Power: 3
elelel is on a distinguished road
Has solved!Do you have a better solution? Please tell me!
Code:
fvMesh& mesh = solidRegions[i];
point position = point(0.0425,0.021,0.135);
label mycell = mesh.findCell(position);
const Foam::volScalarField& T = mesh.lookupObject<Foam::volScalarField>("T");
//scalar Tcell = VGREAT;
 //if (mycell != -1)
//{
 scalar Tcell = T[mycell];
//}
reduce(Tcell, maxOp<scalar>());
bool flag ;
for (double tt = 0;tt<100;tt=tt+0.5)
{
if (tt <= runTime.value() < tt+0.5)
  {
  if (Tcell > 310 and runTime.value() == tt)
  {flag = true;}
  if (Tcell <= 310 and runTime.value() == tt)
  {flag = false;}
  }
}

if (flag)
{
        fvScalarMatrix hEqn
        (
            fvm::ddt(betav*rho, h)
          - (
                thermo.isotropic()
              ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
              : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
            )
          ==
            fvOptions(rho, h)
        );

        hEqn.relax();

        fvOptions.constrain(hEqn);

        hEqn.solve();

        fvOptions.correct(h);
}
if (!flag)
{
        fvScalarMatrix hEqn
        (
            fvm::ddt(betav*rho, h)
          - (
                thermo.isotropic()
              ? fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
              : fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
            ) + poy_recv
          ==
            fvOptions(rho, h)
        );

        hEqn.relax();

        fvOptions.constrain(hEqn);

        hEqn.solve();

        fvOptions.correct(h);
}
elelel is offline   Reply With Quote

Reply

Tags
control point, control valve, heat equation, heat source term, value of interest


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 80 May 17, 2022 08:06
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24


All times are GMT -4. The time now is 17:07.