SHARE
TWEET

Untitled

a guest Jun 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from fipy import CellVariable, Grid1D,Viewer, TransientTerm, DiffusionTerm, ImplicitSourceTerm
  2. from fipy.tools import numerix
  3.  
  4. size, dl, q = 100, 3e-6, 14.1
  5. Ds, Ks = 1e-4, 5.8e-4
  6. order = 2
  7. dt = dl ** 2 / (2 * Ds)
  8.  
  9. mesh = Grid1D(dx=dl, nx=size)
  10. phi_s = CellVariable(name='substrate', mesh=mesh)
  11. B = CellVariable(name='biomass', mesh=mesh)
  12.  
  13. B.value[-10:] = 1000
  14. phi_s.constrain(1, mesh.facesLeft)
  15. reactionsCoeff = - q * B * (phi_s + Ks)
  16.  
  17. phi_s.setValue(numerix.linspace(1, 0, size))
  18. equation = DiffusionTerm(coeff=Ds) + ImplicitSourceTerm(coeff=reactionsCoeff) == 0
  19. res = 1e8
  20. while res > 1e-4:
  21.     res = equation.sweep(var=phi_s)
  22.     print(phi_s.value[::20])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top