|
[Sponsors] |
HOW TO STOP CODE & WRITE RESULTS IF THE temperature DIFFERENCE |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
Member
RJSergio Feitoza Costa
Join Date: Sep 2024
Posts: 44
Rep Power: 2 ![]() |
I have a heat transfer case in which I monitor temperatures in a certain region ( heater_1 in code below)at each writeInterval settled in ControlDict file.
I want to stop the code and write the results- before the end time- if the difference between the temperature in the current time and in the previous moment (currentTime minus timeinterval) is lower than a certain value, for example 5K. I suppose that I have to write a code and insert it in ControlDict file. My difficult is to write this code and to know where to insert it. CAN YOU SUGGEST ME A CODE AND WHERE TO INSERT IT IN THIS CONTROLDICT TEXT FILE ? Thank you in advance (controldict file in next lines) /*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 12 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application foamMultiRun; regionSolvers //definição das diferentes regiões que compõem a simulação { fluid fluid; metal solid; heater_1 solid; } //Time Control startFrom startTime; startTime 0; stopAt endTime; // or stop if the temperature difference to the previous writeinterval is lower than 5K endTime 10800; deltaT 120;/ //Data Writing writeControl adjustableRunTime; writeInterval 1200; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 7; //Others Settings runTimeModifiable true; maxCo 750.0; maxDi 750.0;. maxDeltaT 10800; adjustTimeStep yes; // ************************************************** *********************** // Last edited by SergioCosta; February 10, 2025 at 13:44. Reason: include figure to clarify |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
RJSergio Feitoza Costa
Join Date: Sep 2024
Posts: 44
Rep Power: 2 ![]() |
Can anyone give me an example more or less like this ?
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
Member
RJSergio Feitoza Costa
Join Date: Sep 2024
Posts: 44
Rep Power: 2 ![]() |
How to stop the code and write the results if the difference between the temperature in the current time and in the previous write moment (currentTime minus timeinterval) is lower than a certain value, for example 5 degrees.
|
|
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Hosein
Join Date: Nov 2011
Location: Germany
Posts: 99
Rep Power: 15 ![]() |
Hi there,
try adding this code to the end of your controlDict : Code:
functions { heaterTemperatureChecker { libs ("libutilityFunctionObjects.so"); type coded; region heater_1; writeControl timeStep; writeInterval 1; codeExecute #{ const auto& Temperature = mesh().lookupObject<volScalarField>("T"); scalar averageT = Temperature.weightedAverage(mesh().V()).value(); static scalar averageT_old = -10.0; Info << "averageTemperature = " << averageT << endl; if(averageT_old < 0) { averageT_old = averageT; // update old temp. } else { if(averageT - averageT_old > 5) { // end simulation and write results const auto& runTime = mesh().time(); runTime.stopAt(Foam::Time::stopAtControl::writeNow); } else { averageT_old = averageT; // update old temp. } } #}; } } |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Member
RJSergio Feitoza Costa
Join Date: Sep 2024
Posts: 44
Rep Power: 2 ![]() |
still in doubt or want to know why this works watch this video https://youtu.be/xkXtlWp2IKs[/QUOTE]
/////////////////////////////////////////////////////////// Thank you very much einstein_zee for helping me and many other people with this complete class about functions. After seeing your great video, I understood that a more general strategy to fix the moment to stop the simulation is to do If ( (averageT - averageT_old) / time ) < (5K / 3660 s) // lower than 5K per hour SUGGESTION FOR VÍDEO IN YOUR SITE: Imagine an empty metal box suspended in the air at 300K with dimensions 1x1x1 m . Walls and ceiling thickness are 5mm (5E-3m). I put a 100-Watt light bulb inside. The air heats up and I calculate the final average temperature of the air inside as in the figure in the post. Now imagine that the ceiling and floor of the box are made of a metal foam plate with 90% porosity and I put the same light bulb. The air inside will heat up less. If you wish a little bit more complicated suppose that the velocity of the air inside (buoyancy) is 0.025m/s I'm trying to find the right solver and strategy to simulate this. Along the last 20 years of my 70s I developed a non-CFD software easier to manipulate. In this validation document there are comparing test results to simulation results. The results of the tests are rare to find. Maybe can be useful in your teaching classes https://www.cognitor.com.br/TR_150_E...rDesignSWD.pdf P.S: Is there any video in your site showing how to plot charts with Paraview ? Congratulations and thanks again |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
somaFoam - And plasma goes weee | Destouches | OpenFOAM Running, Solving & CFD | 11 | July 17, 2024 06:55 |
Can I write temperature dependent UFD code in ansys fluent expression? | GreyMat | FLUENT | 0 | August 9, 2022 10:53 |
Changing Temperature of patch within code of solver | SalvusApfel | OpenFOAM Pre-Processing | 1 | February 24, 2017 07:29 |
monitoring point of total temperature | rogbrito | FLUENT | 0 | June 21, 2009 17:31 |
State of the art in CFD technology | Juan Carlos GARCIA SALAS | Main CFD Forum | 39 | November 1, 1999 14:34 |