Hello,

First off, I'd like to say I really like FiPy and appreciate that you have
made such great tool for everyone to use. I am trying to use FiPy to solve
a heat transfer problem in 1D and I have a few implementation questions.
Forgive me if they seem simplistic. I have looked at a lot of the
documentation and examples, but there may be some things that have eluded
me. If it seems like I'm writing very simple, obvious things it's just so I
can get a full grasp of what is going on.

1) It seems that most, if not all, of the examples are in Cartesian
coordinates. Thus, a 1D diffusion equation with a source term would be:

[image: image.png]
where rho is density, Cb is specific heat, lamba is an effective heat
transfer and S is a source term. Of course, T is temperature, t is time,
and x is the coordinate.

I would normally set this mesh up by using

mesh = Grid1D(nx =100., Lx = 1., dx = 1./100.)

If I wanted to run this in a cylindrical coordinate grid, the equation
would become:

[image: image.png]
Can I just call the following in FiPy to account for this coordinate system
change?:

mesh = CylindricalGrid1D(nx = 100.,Lx = 1., dx = 1./100.)

If not, how do I account for the dependent variable when it is not in the
differential? Essentially, how do can I put lambda/r in the coefficient
etc.?

2) Is the correct way to add a source term simply to write something like:

eq = TransientTerm() == DiffusionTerm() + S

or

eq = TransientTerm() == DiffusionTerm() + ImplicitSourceTerm(S)?

3) Regarding boundary conditions, I am trying to use a boundary condition
that has my dependent variable (T) in the boundary condition. The condition
is dT/dr = h(T - Tc), where Tc is a constant. Would this be the correct way
to do that? I'm mostly inquiring about writing the dependent variable as
T.faceValue...

T.faceGrad.constrain(h*(T.faceValue - Tc), mesh.facesLeft)


I've included a copy of the code below. There are some extraneous
details/code in there that I was playing with.

Thank you!

-- 
Daniel DeSantis

from fipy import *

# Constants

rho_b_MH = 589. # kg m^-3
Cp_b = 88.25 #kJ (mol*K)^-1,

# I'm using L in place of lambda
L_eg = 150. # W m^-1 K^-1
L_MH = 1.74 # W m^-1 K^-1
L_eff = 8.4 # W m^-1 K^-1

t_r = 3.7 #min

M = 2.02 #g/mol
dH = 28.*1000. #kJ/mol

h = 150. # W/m^-2 K^-1
T_c = 60 # Coolant Temperature

 Equation Set up and Boundary Condition

R = 1. # There was no radius provided. I just set it to 1 for now
nx = 100. # arbitrary number of points
dx= R/nx
#mesh = Grid1D(nx = nx, dx=dx) # Create a "mesh" for the 1D array
mesh = CylindricalGrid1D(nx=nx,dx=dx,Lx=R)


T = CellVariable(name ="Temperature",mesh=mesh,value = 60.)

#T.constrain(60.,mesh.facesLeft)
#T.constrain(120.,mesh.facesRight)
T.faceGrad.constrain(0,mesh.facesRight)
T.faceGrad.constrain(h*(T.faceValue-T_c),mesh.facesLeft)

eq1 = TransientTerm(coeff=rho_b_MH*Cp_b,var=T) == DiffusionTerm(coeff =
L_eff, var = T) + rho_b_MH*(dH/M)

# Equation Solution
vi = Viewer(T,datamin=0,datamax=100)

TSD = .0001 #min/step
steps = 75 #steps
for step in range(steps):
    eq1.solve(var=T,dt=TSD)
    vi.plot()
_______________________________________________
fipy mailing list
fipy@nist.gov
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to