0

我需要一些帮助来解决 FiPy 中一个安静的简单问题。我的目标是模拟相变时流过混凝土块的流体。但首先我尝试做一个简单的一维模拟,假设流体质量流量和壁温恒定,没有任何相变。

from fipy import *
from fipy.meshes import CylindricalGrid2D, Grid1D
import matplotlib.pyplot as plt
import numpy as np

#%%


L = 1.5 #length transfer surface
bS = 0.75 #wide
AV = L * bS #transfer surface

tS0 = 350. #tWall

rhoWF = 880. #density fluid
mWF = 0.036 #mass flow
u = 5e-4 #Fluid speed
hWF = mWF / AV / rhoWF / u #height "fluid block"
nx = 50
VWF = hWF * L * bS/nx #fluid volumen
lambdaWF = 0.6 # thermal conductivity
alpha = 500. #heat transfer coefficient 
tWF0 = 371.



mesh = Grid1D(dx=L/nx, nx=nx)


tWF = CellVariable(name="Fluid", 
                   mesh=mesh, 
                   value= tWF0,
                   hasOld=True)

tS = CellVariable(name="storage", 
                  mesh=mesh, 
                  value=tS0, 
                  hasOld=True)


sourceWF=CellVariable(name="source Fluid",  #Variable der Konvektion
                       mesh=mesh,
                       value=0.)

cvrho = CellVariable(name = 'cprho',#Fluid
                     mesh = mesh,
                     value = rhoWF *  4215.2,
                     hasOld = True) 

tWF.constrain(tWF0, mesh.facesLeft()) #constant inlet temperature

t = 6*3600. #time
timeStepDuration = 1e2

#outflow boundary condition
outlet = mesh.facesRight
ConvCoeff = FaceVariable(mesh,value=u,rank=1)
exteriorCoeff = FaceVariable(mesh,value=0.,rank=1)
exteriorCoeff.setValue(value=ConvCoeff, where=outlet)
ConvCoeff.setValue(0., where=outlet)

residual1 = 1.
elapsedTime = 0.

tWFall = np.zeros(nx)[None,:]

while elapsedTime < t:
    tWF.updateOld()   
    it = 0 #iterations
    while residual1> 1e-2:      

        sourceWF.value = - AV / nx * alpha*(tWF - tS)/ cvrho / VWF #this will be a variable convection source

        eq1 = HybridConvectionTerm(coeff=ConvCoeff) +  TransientTerm(coeff=1.) == \
        + sourceWF\
        - ImplicitSourceTerm(exteriorCoeff.divergence) \
        #+ DiffusionTerm(coeff= lambdaWF / cvrho) #not necessary(?)

        residual1 = eq1.sweep(dt = timeStepDuration, var = tWF)
        print('res1: ' + str(residual1) )
        it += 1
        if it > 10:
            raise ValueError (r'MaxIter reached')  
    elapsedTime += timeStepDuration ; print('t= ' + str(round(elapsedTime,2)))
    residual1 = 1.
    tWFall = np.r_[tWFall, tWF.value[None,:]] #value collection

#%% outlet fluid temperature and storage temperature

plt.plot(np.linspace(0,t/3600.,int(t/timeStepDuration)), tWFall[1:,-1], label=r'$\vartheta_{WF}$')

plt.legend()

由于恒定的壁温和恒定的流体入口温度,我希望流体出口温度恒定。我没有将壁温定义为边界条件,因为有一天我也想分析热传导和可变温度梯度。运行我的 mwe,您可以看到出口处的流体温度下降。在这种情况下有人可以帮忙吗?提前致谢!

4

1 回答 1

0

我改变了脚本,它似乎给出了一个恒定的温度 371.0。请参阅此链接

  • sourceWF术语已被删除。我不确定这是为了什么,但我认为墙壁温度需要一段时间才能适应这一点。

  • 方程声明已移出循环。这是使用 FiPy 的正确方法,但在这种情况下不应影响结果。

于 2018-06-22T15:42:16.773 回答