|
[Sponsors] |
September 1, 2021, 19:26 |
Energy equation in openfoam 2.1
|
#1 |
Member
Join Date: Dec 2020
Posts: 38
Rep Power: 5 |
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)); } Best regards |
|
Tags |
openfoam 2.1 |
|
|
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 20:10 |
Principal variable in energy equation is total enthalpy or total internal energy? | lostking18 | CFX | 3 | June 11, 2019 02:20 |
reactingFOAM with fvOptions for gravity ERROR in energy equation | er99 | OpenFOAM Running, Solving & CFD | 1 | June 3, 2019 12:08 |
Energy equation in OpenFoam | nwpukaka | OpenFOAM Programming & Development | 2 | June 24, 2014 03:40 |
SIMPLE and energy equation convergence | Fabio | Main CFD Forum | 0 | June 1, 2007 07:06 |