Discussion:
thermal contact between two regions
Drew Davidson
2018-07-11 23:00:36 UTC
Permalink
Hello,


I want to do a heat conduction problem with FiPy that is similar to that in
https://www.mail-archive.com/***@nist.gov/msg02626.html “how to implement
a thermal contact between two regions?”


What is different from that thread:

1. Transient heat conduction rather than steady state. Same boundary
conditions but initial condition can be zero temperature eveywhere.

2. The two regions have differing properties (thermal conductivity, mass
density, specific heat)

3. The thermal contact is a true thermal contact resistance (a pure
resistance); it has zero thickness, and it has zero heat capacity.


I tried to guess at code from looking at the aforementioned mailing list
thread, but my understanding of FiPy is too weak; it would be great to see
an authoritative answer.


Thanks
Daniel Wheeler
2018-07-12 13:47:43 UTC
Permalink
Post by Drew Davidson
1. Transient heat conduction rather than steady state. Same boundary
conditions but initial condition can be zero temperature eveywhere.
Add a TransientTerm to the equation and step through the solution with
time steps and sweeps if necessary.
Post by Drew Davidson
2. The two regions have differing properties (thermal conductivity, mass
density, specific heat)
The coefficients can have spatially varying values in FiPy. Define the
coefficients as face or cell variables.
Post by Drew Davidson
3. The thermal contact is a true thermal contact resistance (a pure
resistance); it has zero thickness, and it has zero heat capacity.
I need to see it defined mathematically to understand how to implement
it in FiPy, but I'm confident it's possible to define it.
--
Daniel Wheeler
Drew Davidson
2018-07-12 16:28:26 UTC
Permalink
Hello,


I’m sorry for not being more specific. I was trying to incorporate
https://www.mail-archive.com/***@nist.gov/msg02626.html by reference.



Sketch of problem:


(1)------------ Region 1 --------------* thermal contact resistance *
---------- Region 2 ------------ (2)


Temperature at (1) is zero.

Heat flux at (2) is constant.

At time zero, temperature is everywhere zero.


******

What is a thermal contact resistance?


https://en.wikipedia.org/wiki/Thermal_contact_conductance


A dissertation available free online:

Thermal contact resistance

Author: Mikic, B. B.; Rohsenow, Warren M.

Citable URI: http://hdl.handle.net/1721.1/61449

It’s equation (1.1) on page 12 of this dissertation.


Thermal contact resistance is directly analogous to an electrical resistor
in a simple circuit:

(temperature drop across thermal contact resistance) = (heat flux) * (its
unit-area thermal resistance)

Units: Kelvin = W/m^2 times Kelvin/(W/m^2)


Mathematically, the thermal contact resistance has no thickness and no heat
capacity (it does not store energy).

******


Please look at https://www.mail-archive.com/***@nist.gov/msg02641.html.
Dr. Guyer and Dr. Wheeler considered the case of steady heat flow (steady
state problem with no transient term), and their thermal contact has a
finite thickness ‘dx’. They derived an expression for effective thermal
conductivity at the thermal contact location, and provided FiPy code. How
do things change in a transient problem? What is the effective thermal
diffusivity (thermal diffusivity = thermal conductivity/(mass density *
specific heat)) at the interface location, given that Region 1 and Region 2
have different thermal conductivities, mass densities, and specific heats?
How is it written in FiPy? This is the point at which my knowledge of the
finite volume method and FiPy is too weak.


A solution where the thermal contact has a finite thickness ‘dx’ is also of
interest, since it seems like a thermal contact resistance can be
approximated by setting ‘dx’ very small.


Trying to get on the same page:

thermal diffusivity m^2/s

thermal conductivity W/m/K

mass density kg/m^3

specific heat J/kg/K


Thanks
Post by Daniel Wheeler
Post by Drew Davidson
1. Transient heat conduction rather than steady state. Same boundary
conditions but initial condition can be zero temperature eveywhere.
Add a TransientTerm to the equation and step through the solution with
time steps and sweeps if necessary.
Post by Drew Davidson
2. The two regions have differing properties (thermal conductivity, mass
density, specific heat)
The coefficients can have spatially varying values in FiPy. Define the
coefficients as face or cell variables.
Post by Drew Davidson
3. The thermal contact is a true thermal contact resistance (a pure
resistance); it has zero thickness, and it has zero heat capacity.
I need to see it defined mathematically to understand how to implement
it in FiPy, but I'm confident it's possible to define it.
--
Daniel Wheeler
_______________________________________________
fipy mailing list
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Daniel Wheeler
2018-07-12 18:28:08 UTC
Permalink
I think you can do this by aligning the mesh with the contact region
and specifying the diffusion coefficient at the contact faces.
Post by Drew Davidson
Hello,
I’m sorry for not being more specific. I was trying to incorporate
--
Daniel Wheeler
Drew Davidson
2018-07-17 20:43:37 UTC
Permalink
Hello,


I continued to stare at
https://www.mail-archive.com/***@nist.gov/msg02641.html.


I realized Keff must be effective thermal conductivity as described in:


Salazar, Agust n. “On Thermal Diffusivity.” *European Journal of Physics*
24, no. 4 (July 1, 2003): 351–58. https://doi.org/10.1088/0143-0807/24/4/353
.


For years I sat right next to grad students whose entire degree was in
computing Keff of composite materials via ANSYS/COMSOL, but I still looked
at https://www.mail-archive.com/***@nist.gov/msg02641.html with
incomprehension.


I realized all that was being done in
https://www.mail-archive.com/***@nist.gov/msg02641.html must be to compute
Keff of the finite volume which contains the thermal contact resistance,
and then to assign thermal conductivity of the finite volume face at the
interface to Keff.


The Salazar paper also gives equations for effective thermal diffusivity,
which is what I was asking for in the current thread. Now I think I mostly
have what I need.



I still need FiPy code for:


dAP1/(dAP1+dAP2)


and


dAP2/(dAP1+dAP2)


where dAP1 and dAP2 were distances from cell center to cell face for cells
on either side of the interface. If these FiPy expressions are
unavailable, I would think assuming .5 is going to be OK...



Thanks
Post by Daniel Wheeler
I think you can do this by aligning the mesh with the contact region
and specifying the diffusion coefficient at the contact faces.
Post by Drew Davidson
Hello,
I’m sorry for not being more specific. I was trying to incorporate
--
Daniel Wheeler
_______________________________________________
fipy mailing list
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Daniel Wheeler
2018-07-23 15:28:13 UTC
Permalink
Post by Drew Davidson
dAP1/(dAP1+dAP2)
and
dAP2/(dAP1+dAP2)
where dAP1 and dAP2 were distances from cell center to cell face for cells
on either side of the interface. If these FiPy expressions are unavailable,
I would think assuming .5 is going to be OK...
I think it's outlined in the link that you gave.

Kcontact = hc * mesh._cellDistances
Kavg = Kcell.harmonicFaceValue
K.setValue(Kcontact * Kavg / (Kavg + Kcontact * (1 - dx /
mesh._cellDistances)), where=mesh.physicalFaces['thermal contact'])

m._cellDistances is the distance between each cell and `dx` is the
volume of the cell for a 1D problem.
--
Daniel Wheeler
Drew Davidson
2018-07-23 17:06:29 UTC
Permalink
Hello Dr. Wheeler,

'dx' is actually the thickness of the thermal contact region. It is not
the volume of the cell. If it were a volume, the ratio
dx/mesh._cellDistances would not be dimensionless. I was seeking a thermal
contact region of zero thickness (dx=0), giving a true thermal contact
resistance.

I let this thread drop because the Salazar paper I referenced gave me
expressions for effective thermal conductivity and effective thermal
diffusivity, and this allowed me to arrive at a reasonable-looking FiPy
result for transient thermal behavior. My result still deviates a bit from
the exact solution at steady state, and this deviation persists despite
mesh refinement, but I am busy with other things and have called it good
enough for now.

OK, I won't leave you hanging. Here is the code I was working on. Maybe
you or someone else can spot a defect that would explain why the code does
not exactly replicate the steady state solution. Another thing to do is:
compare the transient result with the transient result obtained another way
(ANSYS etc). I used to have an analytical solution for the transient
laying around, but threw it out in a pile of papers (oops).

#I am trying to look at the script by Wheeler at
#https://www.mail-archive.com/***@nist.gov/msg02640.html
#and modify it in view of Guyer as in
#https://www.mail-archive.com/***@nist.gov/msg02641.html
#now instead of a steady state problem, do a transient problem

import fipy as fp
import numpy as np
from IPython import embed
import sys
import os
import pygmsh
import meshio
import csv
import matplotlib.pyplot as plt
from shutil import copyfile
#head
def
get_uniform_mesh_with_pygmsh(L_Sample,L_Substrate,cellSize,write_to_msh_file=False):
'''
figure it out in ipython
ref: https://github.com/nschloe/pygmsh/blob/master/test/test_pacman.py
'''
geom = pygmsh.built_in.Geometry()

#geom.add.point? see what the input arguments are in ipython using ?
p1=geom.add_point([0,0,0],cellSize)
p2=geom.add_point([L_Substrate,0,0],cellSize)
p3=geom.add_point([L_Substrate+L_Sample,0,0],cellSize)

l1=geom.add_line(p1,p2)
l2=geom.add_line(p2,p3)

#not much point in doing physical groups since have no way to transmit
this info to 1D fipy mesh
# geom.add_physical_point(p1,label='SubstrateEnd')
# geom.add_physical_point(p2,label='TCR')
# geom.add_physical_point(p3,label='SampleEnd')

# geom.add_physical_line(l1,label='Substrate')
# geom.add_physical_line(l2,label='Sample')

points, cells, point_data, cell_data, field_data =
pygmsh.generate_mesh(geom)

if write_to_msh_file:

mesh=meshio.Mesh(points=points,cells=cells,point_data=point_data,cell_data=cell_data,field_data=field_data)
meshio.write('TCR01.msh',mesh)

mesh=get_fipy_1D_mesh_from_points(points)

return mesh

#head
#head
if __name__=='__main__':
#substrate is copper and sample is pure tin

rho_Sample=6980. #use wolfram alpha to get the density of copper;
kg/m^3
cp_Sample=227. #use wolfram alpha to get the specific heat of copper;
J/kg/K
k_Sample=59.6 #W/m/K
D_Sample=k_Sample/rho_Sample/cp_Sample
L_Sample=2e-6 #m SETTING

rho_Substrate=8960. #use wolfram alpha to get the density of copper;
kg/m^3
cp_Substrate=384.4 #use wolfram alpha to get the specific heat of
copper; J/kg/K
k_Substrate=381.8 #W/m/K
D_Substrate=k_Substrate/rho_Substrate/cp_Substrate
L_Substrate=10*L_Sample #m SETTING

#model an interface thermal resistance between copper and solder, with
the solder being soldered to the copper
R_TIM_unit_area=2e-6 #K/(W/m2) SETTING

TIM_target_dT=1. #K SETTING
HeatFlux=TIM_target_dT/R_TIM_unit_area #W/m^2 heat flux is determined
by TIM_target_dT


#using a uniform mesh:
cellSize=.1*L_Sample #SETTING


mesh=get_uniform_mesh_with_pygmsh(L_Sample,L_Substrate,cellSize,write_to_msh_file=False)


#make sure you like the mesh before doing a run
#sys.exit()


diffCoeff = fp.FaceVariable(mesh=mesh, value=D_Substrate)

diffCoeff.setValue(D_Sample,where=(mesh.faceCenters[0]>=L_Substrate))

xCenters,=mesh.cellCenters

#thermal conductivity of a cell if it's R" were R_TIM_unit_area:
Kcontact=1./R_TIM_unit_area*mesh._cellDistances #type is
numpy.ndarray; [W/m/K]

Kcell=fp.CellVariable(mesh=mesh,value=k_Substrate)
Kcell.setValue(k_Sample,where=(xCenters>=L_Substrate))

Kavg = Kcell.harmonicFaceValue #a FaceVariable

#see 20180717EffectiveProperties.xoj
Keff=Kcontact * Kavg / (Kavg + Kcontact) #W/m/K
rho_times_cp_eff=.5*(rho_Substrate*cp_Substrate+rho_Sample+cp_Sample)
#TODO ask on fipy mailing list as to how to express dAP1/(dAP1+dAP2) in
fipy syntax; the factor of .5 here is only approximate

diffCoeff.setValue(Keff/rho_times_cp_eff, where=(mesh.faceCenters[0] ==
L_Substrate))

v = fp.CellVariable(mesh=mesh)
v.constrain(0, where=mesh.facesLeft)
v.faceGrad.constrain(HeatFlux / k_Sample, where=mesh.facesRight)

#follow examples at
https://www.ctcms.nist.gov/fipy/examples/diffusion/generated/examples.diffusion.mesh1D.html#module-examples.diffusion.mesh1D
eq1=fp.TransientTerm()==fp.DiffusionTerm(coeff=diffCoeff) #implicit
dtExplicitLimit_Substrate = cellSize**2 / (2 * D_Substrate)
dtExplicitLimit_Sample = cellSize**2 / (2 * D_Sample)

dtExplicitLimit_InterfaceCell=cellSize**2/(2*Keff.value.mean()/rho_times_cp_eff)
#play with Keff in ipython; .mean seems close enough to what you want

dt=10*min([dtExplicitLimit_Substrate,dtExplicitLimit_Sample,dtExplicitLimit_InterfaceCell])
#SETTING

#viewer=fp.Viewer(vars=(v,),datamin=0,datamax=10.)
viewer=fp.Viewer(vars=(v,))

TJumpAtInterfaceExpected=HeatFlux*R_TIM_unit_area

TJumpInBarNoInterfaceExpected=HeatFlux*(L_Substrate/k_Substrate+L_Sample/k_Sample)

TJumpInBarExpected=TJumpAtInterfaceExpected+TJumpInBarNoInterfaceExpected

blurb='''
at steady state:
expected T jump at interface is %.2E
expected T jump in bar with no interface is %.2E
expected total T jump in bar is %.2E
hit return to continue
''' %
(TJumpAtInterfaceExpected,TJumpInBarNoInterfaceExpected,TJumpInBarExpected)

#run with --inline if you have weave working
steps = 15000 #SETTING
plotEvery=100 #SETTING
saveDataEvery=200 #SETTING

#TODO need code to stop when at thermal steady state

times=[]
rod_dTs=[]

outFilenameBase='20180717UniformMesh04' #SETTING

outFilename=outFilenameBase+'.csv'

assert (not os.path.exists(outFilename)), '%s already exists on disk;
this script requires that you manually update outFilenameBase'

with open(outFilename,'w') as csvfile:
csvWriter = csv.writer(csvfile, delimiter=' ',quotechar='|',
quoting=csv.QUOTE_MINIMAL)
for step in range(steps):

eq1.solve(var=v,dt=dt)

if step%plotEvery==0:
print 'step is %d of %d\n' % (step,steps)
viewer.plot()

if step%saveDataEvery==0:
#saving the temperature drop across the entire rod vs time:
times.append(step*dt)
rod_dTs.append(v.value[-1]-v.value[0])

csvWriter.writerow([step*dt,v.value[-1]-v.value[0]]) #TODO
am looking at values at cell centers; really want face values

raw_input(blurb)

fig, ax = plt.subplots()
ax.plot(times,rod_dTs)

ax.set(xlabel='time (s)', ylabel='temperature drop across entire rod,
K')

ax.grid()

fig.savefig(outFilenameBase+'.png')
plt.show()

raw_input('hit enter to continue')

#make a copy of this script with a new name so you have a good record
of what produced the result
#copyfile(src,dst)

copyfile('ModifyWheelerInViewOfGuyer20130517TransientVersionImplicit03.py',outFilenameBase+'.py')

#don't forget to run with --inline if you have weave installed and
working
Post by Drew Davidson
Post by Drew Davidson
dAP1/(dAP1+dAP2)
and
dAP2/(dAP1+dAP2)
where dAP1 and dAP2 were distances from cell center to cell face for
cells
Post by Drew Davidson
on either side of the interface. If these FiPy expressions are
unavailable,
Post by Drew Davidson
I would think assuming .5 is going to be OK...
I think it's outlined in the link that you gave.
Kcontact = hc * mesh._cellDistances
Kavg = Kcell.harmonicFaceValue
K.setValue(Kcontact * Kavg / (Kavg + Kcontact * (1 - dx /
mesh._cellDistances)), where=mesh.physicalFaces['thermal contact'])
m._cellDistances is the distance between each cell and `dx` is the
volume of the cell for a 1D problem.
--
Daniel Wheeler
_______________________________________________
fipy mailing list
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
Daniel Wheeler
2018-07-23 17:27:17 UTC
Permalink
'dx' is actually the thickness of the thermal contact region. It is not the
volume of the cell. If it were a volume, the ratio dx/mesh._cellDistances
would not be dimensionless. I was seeking a thermal contact region of zero
thickness (dx=0), giving a true thermal contact resistance.
Sorry, my mistake on that one.
I let this thread drop because the Salazar paper I referenced gave me
expressions for effective thermal conductivity and effective thermal
diffusivity, and this allowed me to arrive at a reasonable-looking FiPy
result for transient thermal behavior. My result still deviates a bit from
the exact solution at steady state, and this deviation persists despite mesh
refinement, but I am busy with other things and have called it good enough
for now.
Thanks for following up and sharing your code.
--
Daniel Wheeler
Loading...