• R/O
  • SSH

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

File Info

Rev. e61011792ce9a826e4e54a084d2b5ff2ccf84775
Tamanho 1,400 bytes
Hora 2011-03-29 01:25:27
Autor lorenzo
Mensagem de Log

I added a script solving the diffusion equation on a square.

Content

#! /usr/bin/env python
from fipy import *

nx = 200
ny = nx
dx = 1./nx
dy = dx
L = dx * nx
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)
phi = CellVariable(name = "solution variable",\
                   mesh = mesh,\
                   value = 0.)

D = 1.

valueTopLeft = 0.2
valueBottomRight = 1


valueTopRight = 0.2
valueBottomLeft = 1



x, y = mesh.getFaceCenters()
facesTopLeft = ((mesh.getFacesLeft() )  \
                | (mesh.getFacesTop()))
facesBottomRight = ((mesh.getFacesRight())\
                    | (mesh.getFacesBottom()))


facesTopRight = ((mesh.getFacesLeft() )  \
                | (mesh.getFacesTop() ))


facesBottomLeft = ((mesh.getFacesRight() )\
                    | (mesh.getFacesBottom() ))



BCs = (FixedValue(faces=facesTopLeft, value=valueTopLeft),\
       FixedValue(faces=facesTopRight, value=valueTopRight),\
       FixedValue(faces=facesBottomRight, value=valueBottomRight),\
       FixedValue(faces=facesBottomLeft, value=valueBottomLeft))


if __name__ == '__main__':
    viewer = Viewer(vars=phi, datamin=0., datamax=1.)




DiffusionTerm().solve(var=phi, \
                      boundaryConditions = BCs)
if __name__ == '__main__':
    viewer.plot()


# print numerix.allclose(phi(((L,), (0,))), valueBottomRight, atol = 1e-2)

if __name__ == '__main__':
    raw_input("Implicit steady-state diffusion. Press <return> to proceed...")

print "So far so good"