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

Energy equation in openfoam 2.1

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 1, 2021, 18:26
Default Energy equation in openfoam 2.1
  #1
Member
 
Join Date: Dec 2020
Posts: 38
Rep Power: 5
ulugbey is on a distinguished road
Hi,
I have a inhouse solver which is based on Openfoam 2.1.
When the energy equation is solved according to internal energy, the solver can be compiled. But When the energy equation is solved according to enthalpy, the solver cannot be compiled.
Energy equation according to internal energy is as follows:
Code:
{
// total enthalpy equation:
    
        //volScalarField k("k", thermo.Cp()*turbulence->muEff()/PrT); // thermal conductivity
            //volScalarField divrhoHPFlux = fvc::div(Riemann.rhoHFlux()+Riemann.pFlux());
            volScalarField divrhoHFlux = fvc::div(Riemann.rhoEFlux());
            //volScalarField divPFlux = fvc::div(Riemann.pFlux());
      
      solve
      (
        fvm::ddt(rhoE)     
        + divrhoHFlux                
        - fvc::laplacian(turbulence->alphaEff(), hs) // thermal Diffusion
        //+ fvc::laplacian(turbulence->alphaEff(), hs) // thermal Diffusion
        //- fvc::laplacian(k,T) // thermal Conduction
        ==
        fvc::div(sigmaDotU)
        + combustion->Sh()  // Source for enthalpy equation in reactive flows
      );
        
        hs.dimensionedInternalField() = rhoE.dimensionedInternalField() / rho.dimensionedInternalField() - 0.5*magSqr(U.dimensionedInternalField())+p.dimensionedInternalField()/rho.dimensionedInternalField(); //- turbulence->k()().dimensionedInternalField();
        Info<< " Old hs  min...max   = " << min(hs).value() << " ... " << max(hs).value() << endl;    
        Info<< " Old T   min...max   = " << min(T).value() << " ... " << max(T).value() << endl;

        if(temperatureFix)
        {
                  scalar Tlow = 280.0;
            Info << "TEMPERATURE ACTIVE" << endl;
            volScalarField dummyT(T);  //
            forAll(dummyT,i) dummyT[i] = Tlow;    // a volScalarField of the correct size and dimension with value = Tlow            
            //volScalarField lowestE(e);
            volScalarField lowestHs(hs);
            thermo.hsFromT(lowestHs,dummyT); // hs is computed to result in a temperature of Tdummy for the local composition in each cell
            //thermo.eFromT(lowestE,dummyT); // e is computed to result in a temperature of Tdummy for the local composition in each cell
            //e = max(e,lowestE);
            hs = max(hs,lowestHs);
            rhoE = rho * (hs + 0.5*magSqr(U)-p/rho);
        }

            //hs=min(hs,hsMax);
            //hs=max(hs,hsMin);
            //rhoH = rho * (hs + 0.5*magSqr(U));
        
       //  Info<< " New hs  min...max   = " << min(hs).value() << " ... " << max(hs).value() << endl;
      //   Info<< " New T   min...max   = " << min(T).value() << " ... " << max(T).value() << endl;

            hs.correctBoundaryConditions();
        //thermo.correct();
            rhoE.boundaryField() = rho.boundaryField() * ( hs.boundaryField() + 0.5*magSqr(U.boundaryField())+p.boundaryField()/rho.boundaryField());
        //rhoH = rho*(hs + 0.5*magSqr(U));
   
}

Energy equation according to enthalpy is as follows:

Code:
{
// total enthalpy equation:
    
        //volScalarField k("k", thermo.Cp()*turbulence->muEff()/PrT); // thermal conductivity
            //volScalarField divrhoHPFlux = fvc::div(Riemann.rhoHFlux()+Riemann.pFlux());
            volScalarField divrhoHFlux = fvc::div(Riemann.rhoHFlux());
            volScalarField divPFlux = fvc::div(Riemann.pFlux());
      
      solve
      (
        fvm::ddt(rhoH)     
        + divrhoHFlux    
        + divPFlux            
        - fvc::laplacian(turbulence->alphaEff(), hs) // thermal Diffusion
        //+ fvc::laplacian(turbulence->alphaEff(), hs) // thermal Diffusion
        //- fvc::laplacian(k,T) // thermal Conduction
        - fvc::div(sigmaDotU)
        ==
         fvc::ddt(p)
        + combustion->Sh()  // Source for enthalpy equation in reactive flows
      );
        
        hs.dimensionedInternalField() = rhoH.dimensionedInternalField() / rho.dimensionedInternalField() - 0.5*magSqr(U.dimensionedInternalField()); //- turbulence->k()().dimensionedInternalField();
        Info<< " Old hs  min...max   = " << min(hs).value() << " ... " << max(hs).value() << endl;    
        Info<< " Old T   min...max   = " << min(T).value() << " ... " << max(T).value() << endl;

        if(temperatureFix)
        {
                  scalar Tlow = 280.0;
            Info << "TEMPERATURE ACTIVE" << endl;
            volScalarField dummyT(T);  //
            forAll(dummyT,i) dummyT[i] = Tlow;    // a volScalarField of the correct size and dimension with value = Tlow            
            //volScalarField lowestE(e);
            volScalarField lowestHs(hs);
            thermo.hsFromT(lowestHs,dummyT); // hs is computed to result in a temperature of Tdummy for the local composition in each cell
            //thermo.eFromT(lowestE,dummyT); // e is computed to result in a temperature of Tdummy for the local composition in each cell
            //e = max(e,lowestE);
            hs = max(hs,lowestHs);
            rhoH = rho * (hs + 0.5*magSqr(U));
        }

            //hs=min(hs,hsMax);
            //hs=max(hs,hsMin);
            //rhoH = rho * (hs + 0.5*magSqr(U));
        
       //  Info<< " New hs  min...max   = " << min(hs).value() << " ... " << max(hs).value() << endl;
      //   Info<< " New T   min...max   = " << min(T).value() << " ... " << max(T).value() << endl;

            hs.correctBoundaryConditions();
        //thermo.correct();
            rhoH.boundaryField() = rho.boundaryField() * ( hs.boundaryField() + 0.5*magSqr(U.boundaryField()));
        //rhoH = rho*(hs + 0.5*magSqr(U));
   
}
What could be a problem ? How can I be able to compile the solver when the energy equation is solved according to enthalpy?


Best regards
ulugbey is offline   Reply With Quote

Reply

Tags
openfoam 2.1


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
rhosimplefoam : error in solving the energy equation Zal OpenFOAM Running, Solving & CFD 21 April 21, 2022 19:10
Principal variable in energy equation is total enthalpy or total internal energy? lostking18 CFX 3 June 11, 2019 01:20
reactingFOAM with fvOptions for gravity ERROR in energy equation er99 OpenFOAM Running, Solving & CFD 1 June 3, 2019 11:08
Energy equation in OpenFoam nwpukaka OpenFOAM Programming & Development 2 June 24, 2014 02:40
SIMPLE and energy equation convergence Fabio Main CFD Forum 0 June 1, 2007 06:06


All times are GMT -4. The time now is 11:46.