Hi there,
I'm looking for a bit of assistance in how to organize a Fipy script I am
trying to write. I am very new to programming so please forgive me if this
becomes overly evident as I go on.
The physical problem is rather simple and I believe the code to solve it
should be as well, but I have gone through every example and FAQ guide I
can get my hands on and still can't seem to get it right.
I am trying to model the temperature profile in a thermohydraulic loop.
Specifically, right now I would just like to look at the 1D transient
conduction occurring through Inconel 600 (what the pipe is made of).
Temperature depends on the material's thermal conductivity (obviously), but
the thermal conductivity of Inconel 600 in turn changes slightly with
temperature. (The specific equation is: k = (k0) * e^(omega*temp) ),
where k0 and omega are given.
I am fairly certain that interations, sweeps and time steps are required
but I am having trouble organizing it properly to that effect.
Here is what I have done so far: (again, if it seems as though I've made a
giant rookie mistake, that's because I am one!)
from fipy import *
L = 1.
nx = 50.
dx = L / nx
mesh = Grid1D(nx=nx, dx=dx)
# Some definitions
omega = 0.00164
k0 = 11.83
# Create cell variable objects
temp = CellVariable(mesh=mesh, name='Temperature', hasOld=1)
therm_cond = CellVariable(mesh=mesh, name='Thermal Conductivity', hasOld=1)
import math
setValue.therm_cond(k0 * (math.exp(omega * temp)))
# Boundary conditions
outerFlux = 100
outerTemp = 100
BCs = (FixedValue(faces=mesh.getFacesLeft(), value=outerTemp),\
FixedFlux(faces=mesh.getFacesRight(), value=outerFlux),)
eq = TransientTerm() == DiffusionTerm(coeff=therm_cond)
# From the FiPy FAQ section...
mySolver = LinearPCGSolver(iterations = 50, tolerance = 5e-6)
elapsedTime = 0
totalElapsedTime = 300
timeStep = 1
desiredResidual = 1e-4
while elapsedTime < totalElapsedTime:
therm_cond.updateOld()
temp.updateOld()
while residual > desiredResidual:
residual = eq.sweep(var=(temp, therm_cond), dt=timeStep)
elapsedTime += timeStep
if __name__ == '__main__':
viewer = Viewer(vars=(temp, therm_cond))
viewer.plot()
I really appreciate any help that anyone can offer me...even if it means
ripping my work to shreds (I can take it, so by all means...).
Kendall
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]