- Timestamp:
- 06/19/2008 11:38:21 AM (7 months ago)
- Location:
- trunk/examples/diffusion
- Files:
-
- 1 added
- 1 modified
-
anisotropy.msh (added)
-
anisotropy.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/diffusion/anisotropy.py
r2591 r2601 67 67 68 68 >>> from fipy import * 69 >>> cellSize = 0.0370 >>> radius = 1.71 69 72 Create the mesh withGmsh.70 Import a mesh previously created using Gmsh. 73 71 74 >>> lines = [ 'cellSize = ' + str(cellSize) + ';\n', 75 ... 'radius = ' + str(radius) + ';\n', 76 ... 'Point(1) = {0, 0, 0, cellSize};\n', 77 ... 'Point(2) = {-radius, 0, 0, cellSize};\n', 78 ... 'Point(3) = {0, radius, 0, cellSize};\n', 79 ... 'Point(4) = {radius, 0, 0, cellSize};\n', 80 ... 'Point(5) = {0, -radius, 0, cellSize};\n', 81 ... 'Circle(6) = {2, 1, 3};\n', 82 ... 'Circle(7) = {3, 1, 4};\n', 83 ... 'Circle(8) = {4, 1, 5};\n', 84 ... 'Circle(9) = {5, 1, 2};\n', 85 ... 'Line Loop(10) = {6, 7, 8, 9} ;\n', 86 ... 'Plane Surface(11) = {10};\n'] 87 88 89 90 >>> mesh = GmshImporter2D(lines) 72 >>> mesh = GmshImporter2D(os.path.splitext(__file__)[0] + '.msh') 91 73 92 74 Set the center most cell to have a value. … … 94 76 >>> var = CellVariable(mesh=mesh, hasOld=1) 95 77 >>> x, y = mesh.getCellCenters() 96 >>> circleRadius = radius / 10.097 78 >>> var[numerix.argmin(x**2 + y**2)] = 1. 98 79 … … 132 113 >>> X, Y = numerix.dot(mesh.getCellCenters(), CellVariable(mesh=mesh, rank=2, value=rotationMatrix)) 133 114 >>> solution = mass * numerix.exp(-(X**2 / gamma_prime[0][0] + Y**2 / gamma_prime[1][1]) / (4 * time)) / (4 * numerix.pi * time * numerix.sqrt(gamma_prime[0][0] * gamma_prime[1][1])) 134 >>> if int(os.popen4('gmsh --version')[1].read().split('.')[0]) < 2: 135 ... tolerance = 0.14 136 ... else: 137 ... tolerance = 0.06 138 >>> print max(abs((var - solution) / max(solution))) < tolerance 115 >>> print max(abs((var - solution) / max(solution))) < 0.05 139 116 True 140 117
FiPy: A Finite Volume PDE Solver Using Python