Last active
June 9, 2019 13:13
-
-
Save guyer/aa70cb08ac386f1d64f1f93f4890e54d to your computer and use it in GitHub Desktop.
Example script from https://github.com/usnistgov/fipy/issues/649
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
from fipy import CellVariable, Grid1D,Viewer, TransientTerm, DiffusionTerm, ImplicitSourceTerm | |
from fipy.tools import numerix | |
size, dl, q = 100, 3e-6, 14.1 | |
Ds, Ks = 1e-4, 5.8e-4 | |
order = 2 | |
dt = dl ** 2 / (2 * Ds) | |
mesh = Grid1D(dx=dl, nx=size) | |
phi_s = CellVariable(name='substrate', mesh=mesh) | |
B = CellVariable(name='biomass', mesh=mesh) | |
B.value[-10:] = 1000 | |
phi_s.constrain(1, mesh.facesLeft) | |
reactionsCoeff = - q * B * (phi_s + Ks) | |
phi_s.setValue(numerix.linspace(1, 0, size)) | |
equation = DiffusionTerm(coeff=Ds) + ImplicitSourceTerm(coeff=reactionsCoeff) == 0 | |
res = 1e8 | |
while res > 1e-4: | |
res = equation.sweep(var=phi_s) | |
print(phi_s.value[::20]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment