Dear all,
This is my first experience in the world of finite volume solvers, my
main research area is experimental aerodynamics, so my apologies when
I am asking stupid questions. I am trying to setup fipy so that I can
use it to make my own inverse heat transfer code (we have a very basic
one already working in Matlab).
I am trying to solve a 'simple' transient heat conduction case (see
code below). As boundary condition I have a linearly decreasing heat
flux. Now when fipy solves the problem for a certain time period,
first the temperature goes down (as expected) but halfway it starts
increasing. Now I tried increasing the time period and exactly the
same happens: at halfway the temperature starts increasing again. Can
someone give me a hint on what I am doing wrong?
Thanks,
Ferry
from fipy import *
from scipy.special import erfc
import pylab as p
nx = 100 #No. of elements
L = 5e-2 #Length of domain
dx = L/nx
mesh = Grid1D(dx=dx, nx=nx)
x = mesh.getCellCenters()[0]
tend = 100. #Total simulation time
phi_init = 273. + 50. #Initial temperature
qs = 200. #Heat flux (starting value)
#Initialize temperature
phi = CellVariable(name="solution variable", mesh=mesh, value=phi_init)
#Thermal properties Makrolon
k = 0.15 #Thermal conductivity
rho = 1.2e3 #Density
c = 1.2e3 #Thermal capacity
alpha = k/(rho*c) #Thermal diffusivity
#Diffusion equation
eq = TransientTerm() == ImplicitDiffusionTerm(coeff=alpha)
timeStepDuration = 0.9 * dx**2 /(2*alpha)
steps = int(ceil(tend/timeStepDuration))
temp_tab = arange(steps)*0.1
time = Variable()
BCs = (FixedFlux(faces=mesh.getFacesLeft(), value=qs*(1-time/
tend)*alpha/k))
if __name__ == '__main__':
viewer = Viewer(vars=phi)
for step in range(steps):
time.setValue(time() + timeStepDuration)
#res = 1.
#while res > 1e-5:
# res = eq.sweep(phi, dt=timeStepDuration, boundaryConditions=BCs)
eq.solve(phi, dt=timeStepDuration, boundaryConditions=BCs)
temp_tab[step] = phi.getValue()[0]
#q_tab[step] = q
if __name__ == '__main__':
viewer.plot()
p.figure(11)
p.plot(temp_tab)
p.show()