Created
February 5, 2015 16:06
-
-
Save wd15/dd9d9950169fb570c564 to your computer and use it in GitHub Desktop.
mesh2Dvector.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fipy as fp | |
nx = ny = 20 | |
mesh = fp.Grid2D(nx=nx, ny=ny, dx=0.25, dy=0.25) | |
noise = fp.GaussianNoiseVariable(mesh=mesh, | |
mean=0.5, | |
variance=0.01).value | |
dexp = -5 | |
elapsed = 0. | |
duration = .5e-1 | |
var = fp.CellVariable(mesh=mesh, elementshape=(2,)) | |
var[0] = noise | |
D = a = epsilon = 1. | |
v0 = var[0] | |
dfdphi = a**2 * 2 * v0 * (1 - v0) * (1 - 2 * v0) | |
dfdphi_ = a**2 * 2 * (1 - v0) * (1 - 2 * v0) | |
d2fdphi2 = a**2 * 2 * (1 - 6 * v0 * (1 - v0)) | |
source = (- d2fdphi2 * v0 + dfdphi) * (0, 1) | |
impCoeff = -d2fdphi2 * ((0, 0), | |
(1., 0)) + ((0, 0), | |
(0, -1.)) | |
eq = fp.TransientTerm(((1., 0.), | |
(0., 0.))) == fp.DiffusionTerm([((0., D), | |
(-epsilon**2, 0.))]) + fp.ImplicitSourceTerm(impCoeff) + source | |
print 'class:',source.__class__ | |
print 'shape:',source.shape | |
print 'rank:',source.rank | |
dexp = -5 | |
elapsed = 0. | |
while elapsed < duration: | |
dt = min(100, fp.numerix.exp(dexp)) | |
elapsed += dt | |
dexp += 0.01 | |
eq.solve(var=var, dt=dt) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment