图像包括控制方程,初始条件和边界条件。描述了板与流体之间的传热问题。 我不知道如何使用fipy来编码包含var的2-d问题和边界条件。 这是我的尝试。
class UploadHandler(tornado.web.RequestHandler):
# ...
def post(self):
for field_name, files in self.request.files.items():
for info in files:
filename = info['filename'] # name of the file
# NOTE: as pointed out by Ben Darnell, if user submitted
# filename contains special characters like "../",
# it poses a security risk. You should generate your
# own filenames. See `uuid.uuid4()`.
body = info['body'] # contents of the file
with open('video/%s' % filename, 'w') as f:
f.write(body)
self.write('Upload successful')
我发现它失败了。我不知道哪里出了问题。我会欢迎任何帮助;非常感谢! 顺便说一句,我希望获得的最终图像就像enter image description here ......很多人!
答案 0 :(得分:1)
[编辑以修正一般边界条件]
以下运行并且似乎给出了您正在寻找的性质的结果:
from fipy import *
import numpy as np
#constant
Pe=2400.
le_L=1./20000.
L_l=20000.
alphasx=alphasy=1.
alphaf=1.
Bi=0.4
c=Bi/Pe*L_l
Dsxx = alphasx
Dsyy = alphasy * L_l**2
Ds = 1./Pe * le_L * (1./alphaf) * Variable([[alphasx, 0.],
[0., alphasy * L_l**2]])
Df = Variable([[1./Pe * le_L, 0],
[0., 0.]])
#generate
mesh=Grid2D(Lx=1.,Ly=1.,nx=100, ny=100)
Ts=CellVariable(mesh=mesh,name='Ts',value=900.)
Tf=CellVariable(mesh=mesh,name='Tf',value=900.)
#condition
bottom_mask = (mesh.facesBottom * mesh.faceNormals).divergence
dPR = mesh._cellDistances[mesh.facesBottom.value][0]
Af = mesh._faceAreas[mesh.facesBottom.value][0]
bottom_coeff = bottom_mask * Ds[1,1] * Af / (1 + dPR)
Tf.constrain(300,mesh.facesLeft)
#eq
eq1=(TransientTerm(var=Ts)==DiffusionTerm(coeff=Ds,var=Ts)
+ ImplicitSourceTerm(coeff=bottom_coeff * -Bi, var=Tf)
- ImplicitSourceTerm(coeff=bottom_coeff * -Bi, var=Ts))
eq2=(TransientTerm(var=Tf)==DiffusionTerm(coeff=Df,var=Tf)
-ExponentialConvectionTerm(coeff=[[1.], [0]],var=Tf)
+ImplicitSourceTerm(c,var=Tf)
-ImplicitSourceTerm(c,var=Ts))
eq=eq1&eq2
#solve
dt=0.01
steps=100
viewer=Viewer(vars=(Ts,Tf),datamax=1000,datamin=0)
for i in range(steps):
eq.solve(dt=dt)
viewer.plot()
您可能还想引入扫描来解释方程与边界条件之间的非线性相关性。