# How to control the heat source according to the temperature of a point？

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 13, 2022, 09:49 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 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.

 December 19, 2022, 10:18 #2 Senior Member   Join Date: Dec 2019 Location: Cologne, Germany Posts: 355 Rep Power: 8 fvOptions or fvModels should do the trick here.

 January 3, 2023, 04:15 control the temperature every 0.5s #3 New Member   chenfuqiang Join Date: Nov 2022 Posts: 3 Rep Power: 3 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("T"); scalar Tcell = T[mycell]; reduce(Tcell, maxOp()); // 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!

 January 3, 2023, 09:41 Has solved #4 New Member   chenfuqiang Join Date: Nov 2022 Posts: 3 Rep Power: 3 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("T"); //scalar Tcell = VGREAT; //if (mycell != -1) //{ scalar Tcell = T[mycell]; //} reduce(Tcell, maxOp()); 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); }```