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

Adding a temperature dependent FvOptions in ChtMultiRegionFoam for an electric oven

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 16, 2024, 06:31
Default Adding a temperature dependent FvOptions in ChtMultiRegionFoam for an electric oven
  #1
New Member
 
Arunkl
Join Date: Jun 2024
Posts: 7
Rep Power: 2
arunkl is on a distinguished road
I am new to heat transfer solvers in openfoam and working to simulate an electric oven. in this there is four coils and air region. I am using chtMultiRegionFoam for this as it has multiple regions. I have came through Fvoptions which is time dependent but i need to model Temperature dependent so that if the mean temperature increases upto 250 C it should supply heat and turn off the heat source. Again if the temperature reduces it should on the heat source. I have attached the basic Coding i have done and thankyou in advance for your most thankful help... this is for natural convection to the air
Code:
options
{
    energySource
    {
        type            scalarSemiImplicitSource;
        selectionMode   cellSet;
        cellSet         ignition;

        volumeMode      specific;
        sources
        {
            h           (2e7 0);  // kg/m/s^3
        }

        // Temperature-dependent behavior
        code
        #{
            // Get the mean temperature from the temperature field
            const scalar T_mean = T.mean();  // Assuming T is the temperature field variable

            // Check if T_mean exceeds 250 °C
            if (T_mean >= 250 + 273.15)  // Convert 250 °C to Kelvin
            {
                return 0;  // Turn off the heat source if T_mean is 250 °C or higher
            }
            else
            {
                // Return the source value only if the temperature is below 250 °C
                return h;  // Return the defined source value
            }
        #};
    }
}
if there any mistake kindly feel free to say in the thread and it would be very helpful and the version used is ise version v2212
thank you
arunkl is offline   Reply With Quote

Old   April 3, 2025, 07:45
Default
  #2
Senior Member
 
Lasse Brams Vinther
Join Date: Oct 2015
Posts: 119
Rep Power: 11
Swagga5aur is on a distinguished road
Hello Arunkl,

I'm not 100% certain in the best way to do this, however, one solution I could think of is to use scarcodedsource with the if statement inside the source equation or in the solver, further described below.

Code:
energySource
{
    type            scalarCodedSource;	//scalarSemiImplicitSource
    active          true;
    name	    sourceTime;

    scalarCodedSourceCoeffs	//scalarSemiImplicitSourceCoeffs    S(x) = Su + Sp*x  //   q in [W]; or in [W/m³] if you use specific mode
    {
        selectionMode   cellZone;
        cellZone        porousity1;
	fields 		(h);

	fieldNames	(h);
	name		sourceTime;

        codeInclude
        #{

        #};

        codeCorrect
        #{
//            Pout<< "**codeCorrect**" << endl;
        #};

        codeAddSup
        #{
//            const Time& time = mesh().time();
            const scalarField& V = mesh_.V();
            const vectorField& C = mesh_.C();
	    const volVectorField& U = mesh().lookupObject<volVectorField>("U");
	    const volScalarField z = U.mesh().C() & vector(0,0,1);

            scalarField& hSource = eqn.source();
            forAll(C, i)
            {
            	hSource[i] -= 6*((497530 - 530371*exp(-174.834*mag(0.311582803726196-z[i])))*V[i]);
            }
//            Pout << "***codeAddSup***" << endl;
        #};

        codeSetValue
        #{
//            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}
If it's not possible directly in the fvOptions, try and incorporate the average Temperature field in your solver for just the region, a solver I have made previously shows how to do computations for a cellzone differently for the remaining solver, and then using that with the scalar coded source.

https://github.com/Swagga5aur/chtMultiRegionReactorFoam

I sadly don't have much time privately, so hope this can help you along.

Best regards,
Lasse Brams Vinther
Swagga5aur is offline   Reply With Quote

Reply

Tags
cht modelling, chtmultiregion, chtmultiregionfoam, heat and mass transfer, openfoam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 09:21
Averaging over iterations for steady-state simulation CFD student Fluent UDF and Scheme Programming 8 September 22, 2022 03:39
Help with chtMultiRegionFoam jbvw96 OpenFOAM Running, Solving & CFD 2 December 26, 2010 17:16
Adding a new temperature dependent viscositymodel? dgadensg OpenFOAM Programming & Development 10 May 22, 2010 05:47
flow simulation across a small fan jane luo Main CFD Forum 15 April 12, 2004 17:49


All times are GMT -4. The time now is 08:49.