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

Defining a heat flux profile to wall

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By saidc.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 15, 2024, 12:42
Post Defining a heat flux profile to wall
  #1
Member
 
cal
Join Date: Feb 2020
Location: nowhere
Posts: 65
Rep Power: 6
saidc. is on a distinguished road
Hi,

I am trying to define a heat flux polynomial equation as a function of height on the wall. So far, I haven't been successful with the attempts I've made. First, I used the codedMixed boundary condition, and my 0/T file is as follows:
Code:
heatFluxWall
{
	type            codedMixed;
	value           uniform 865; // Initial value
	refValue        uniform 0;   // Reference value (not used in this case)
	refGradient     uniform 0;   // Reference gradient
	valueFraction   uniform 0;   // Fraction of the value that is fixed
	name            sscHeatFlux;
	
	code
	#{
		const fvPatch& boundaryPatch = patch();
		const fvBoundaryMesh& boundaryMesh = boundaryPatch.boundaryMesh();
		const fvMesh& mesh = boundaryMesh.mesh();
		
		const vectorField& Cf = boundaryPatch.Cf();
		scalarField& field = *this;
		
		const vectorField& faceAreas = mesh.Sf();
		const scalarField faceMagnitudes = mag(faceAreas);
		
		this->valueFraction() = 0.0;
		this->refValue() = 0.0;
		scalarField& refGradField = this->refGrad(); // Access refGrad as a scalarField
		
		// Coefficients for thermal conductivity kappa(T) 
		scalar kappaCoeffsArray[] = {myKappa(T)polynomial};
		const scalarField kappaCoeffs(8, kappaCoeffsArray);

		auto evaluateKappa = [&](scalar T) {
			scalar kappa = 0.0;
			scalar T_power = 1.0;
			for (int j = 0; j < kappaCoeffs.size(); ++j)
			{
				kappa += kappaCoeffs[j] * T_power;
				T_power *= T;
			}
			return kappa;
		};

		forAll(field, i)
		{
			scalar yValue1 = Cf[i].y();
			scalar T = field[i]; // Assuming field[i] gives the temperature at the face
			scalar kappa = evaluateKappa(T);
			
			scalar heatFlux = myEquation;
							  
			refGradField[i] = heatFlux / kappa; // Divide by thermal conductivity kappa
		}
	#};
}
Secondly, I used the groovyBC boundary condition, but I couldn't get a result from that either. It is as follows:
Code:
heatFluxWallgroovy
{
	type            groovyBC;
	valueExpression "T"; // Initial value
	variables "
		kappa=myKappa(T)polynomial; //I guess this is wrong. I should access to k on ith face and then use that value?
                yVal=pos().y;
                heatFlux=myEquation(yVal)";
	gradientExpression "heatFlux / kappa";
	valueFraction   uniform 0;
}
I think I am making a mistake while trying to define the heat flux as a gradient on the boundary.

I thought I could define the dT/dx gradient using the Fourier law q = -k dT/dx.
dT/dx = -q/k
If there is a more accurate method or if you identify the error, I would appreciate it if you could share it.

Kind regards,
said
saidc. is offline   Reply With Quote

Old   August 16, 2024, 17:26
Post
  #2
Member
 
cal
Join Date: Feb 2020
Location: nowhere
Posts: 65
Rep Power: 6
saidc. is on a distinguished road
Hi,

When I compared the heat flux values obtained on the wall using the boundary condition I defined with groovyBC, leveraging Fourier's Law with a constant k, to my existing data, I encountered significantly overestimated values. Therefore, I used the externalWallHeatFluxTemperature boundary condition as shown below instead of groovyBC and achieved accurate results. I'm sharing this as a snippet for anyone who encounters a similar issue.

Code:
HFregion
{
	type            externalWallHeatFluxTemperature;
	mode            flux;
	q
	{
		type        coded;
		code
		#{
			auto sscQ = tmp<scalarField>::New(patch_.size(), 10000.0);
			auto& qq = sscQ.ref();
			const vectorField& sscCF = patch_.faceCentres();
			forAll(qq, i)
			{
				scalar yy = sscCF[i].y();
				qq[i] = myPolynomial_Equation;
			}
			return sscQ;
		#};
	}
	kappaMethod     solidThermo;
	value           $internalField;
}
Regards,
said
talop likes this.

Last edited by saidc.; August 16, 2024 at 17:27. Reason: grammer
saidc. is offline   Reply With Quote

Reply

Tags
codedmixed, groovybc, heat flux


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
[snappyHexMesh] How to draw a 3D-Drawing for Meshing Kahnbein.Kai OpenFOAM Meshing & Mesh Conversion 4 June 15, 2021 13:16
Heat loss through wall to surroundings, wall Heat flux Vishnu_bharathi CFX 4 December 20, 2017 19:36
Question about adaptive timestepping Guille1811 CFX 25 November 12, 2017 18:38
Basic Nozzle-Expander Design karmavatar CFX 20 March 20, 2016 09:44
wall heat flux in openfoam hz283 OpenFOAM 1 January 4, 2014 08:51


All times are GMT -4. The time now is 20:30.