SHARE
TWEET

Untitled

a guest Feb 17th, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import math
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4.  
  5. def mu1(C1):
  6.     return ((5.5*C1*C1) - (14.7*C1) + 14.6)
  7.  
  8. def mu2(C2):
  9.     return ((0.55 - (0.3*C2))*C2 + 1.0)
  10.  
  11. def k1(s):
  12.     return (pow(((s - 0.26) / 0.715),3))
  13.  
  14. def k2(s):
  15.     return (pow(((0.8 - s)/0.81),3))
  16.  
  17. def F(s, C1, C2):
  18.     mu = (mu2(C2)/mu1(C1))
  19.     return (k2(s)/(k2(s) + (mu*k1(s))))
  20.  
  21. K = 2.0
  22. h = 0.01
  23. l = 0.001
  24. n1 = 200
  25. n2 = 1000
  26. C1 = [[0 for j in range(n2)] for i in range(n1)]
  27. C2 = [[0 for j in range(n2)] for i in range(n1)]
  28. s = [[0 for j in range(n2)] for i in range(n1)]
  29.  
  30. for j in range(n2):
  31.     s[0][j] = 0.0
  32.     C1[0][j] = 1.0
  33.     C2[0][j] = C1[0][j] / K
  34.  
  35. for i in range(n1):
  36.     s[i][0] = 0.2
  37.     C1[i][0] = 0.0
  38.     C2[i][0] = 0.0
  39.  
  40. for j in range(0, n2-1):
  41.     for i in range(1, n1):
  42.         C2[i][j] = C1[i][j] / K
  43.         a = ((K - ((K - 1) * F(s[i][j], C1[i][j], C2[i][j])))/(1.0 + (s[i][j]*(K - 1))))
  44.         C1[i][j+1] =  C1[i][j] - ((l / h) * a * (C1[i][j] - C1[i-1][j]))
  45.         s[i][j+1] = s[i][j] + ((l / h)*(F(s[i][j], C1[i][j], C2[i][j]) - F(s[i-1][j], C1[i-1][j], C2[i-1][j])))
  46.  
  47. for i in range(0, n1):
  48.     print (1-s[i][100])
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
Top