def TwoGaussianImmuneResponse2D(strength, x, y, Ra): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz))/numerix.sqrt(2*numerix.pi*2*dz)) return ((strength) * numerix.exp(-((x + 0.6)**2 + (y - 0.3)**2) / (2 * Ra)) + (strength) * numerix.exp(-((x - 0.6)**2 + (y - 0.2)**2) / (2 * Ra))) / (numerix.sqrt( 2 * numerix.pi * Ra))
def loopGaussianKernel(z, dz): n = z.shape[0] m = z.shape[0] kern = sp.lil_matrix((n, m), dtype=np.float64) # kern = numerix.zeros((n,m)) # eps = 1e-10 eps = dz**2 digits = len(str(n - 1)) delete = "\b" * (digits + 1) for i in range(n): #if i>0: # for j in range(m): # if j>0: # kern[i, j] = numerix.exp((-(2*z[i] - z[j])**2)/(2*eps)) kern[i] = numerix.exp((-(2 * z[i] - z)**2) / (2 * eps)) # kern = kern + sp.coo_matrix((np.array([numerix.exp((-(2*z[i] - z[j])**2)/(2*eps))]), (np.array([i]), np.array([j]))), shape=(n, m)) # kern.tocsc() #/numerix.sqrt(2*numerix.pi*eps) # print "{0}{1:{2}}".format(delete, i, digits), # level = int((np.float(i)/np.float(n))*100) # print "{0}%\r".format((np.float(i)/np.float(n)*100)) # print "#"*(level+1), return kern / numerix.sqrt(2 * numerix.pi * eps)
def gaussianKernel(z, dz): Z = np.ones((z.shape[0], 1)) * np.array([z]) eps = dz**2 kern = np.exp(-(2 * Z.T - Z) * (2 * Z.T - Z) / (2 * eps)) return kern / numerix.sqrt(2 * numerix.pi * eps)
def GaussianKernel2D(strength, x, y, Ra): return strength * numerix.exp(-( (x**2) + (y**2)) / (2 * Ra)) / (numerix.sqrt(2 * numerix.pi * Ra))
def GaussianKernel(strength, x, Ra): return strength * numerix.exp(-(x**2) / (2 * Ra)) / (numerix.sqrt( 2 * numerix.pi * Ra))
def SigmaF1D(x, Rs): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) # return 0.00001*numerix.exp(-((x)**2)/(2*Rs))/(numerix.sqrt(2*numerix.pi*Rs)) return 10.*numerix.exp(-((x)**2)/(2*Rs))/(numerix.sqrt(2*numerix.pi*Rs))
def AxiSymmetricSigmaF(r, Rs): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return 10*numerix.exp(-((r)**2)/(2*Rs))/(numerix.sqrt(2*numerix.pi*Rs))
def AxiSymmetricGaussianGammaF(r, Rs): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return 0.03 * numerix.exp(-(r**2) / (2 * Rs)) / (numerix.sqrt(2 * numerix.pi * Rs))
def SigmaF2D(amp, x,y, Rs): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return amp*numerix.exp(-(x**2 + y**2)/(2*Rs))/(numerix.sqrt(2*numerix.pi*Rs))
def GaussianConversionRate(r, mean, Rp): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return 0.3*numerix.exp(-(r-mean)**2/(2*Rp))/(numerix.sqrt(2*numerix.pi*Rp))
def gaussianGammaF(x, Rs): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return 0.3 * numerix.exp(-(x**2) / (2 * Rs)) / (numerix.sqrt(2 * numerix.pi * Rs))
def GaussianConversionRate2D(amp, x,y, mean, Rp): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return amp*numerix.exp(-((x-mean)**2 + (y-mean)**2)/(2*Rp))/(numerix.sqrt(2*numerix.pi*Rp))
def gaussianDivisionRate(z, mean, sigma): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz))/numerix.sqrt(2*numerix.pi*2*dz)) return numerix.exp(-(z - mean)**2 / (2 * sigma**2)) / (sigma * numerix.sqrt(2 * numerix.pi))
def AxiSymetricGaussianImmuneResponse(r, Ra): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz))/numerix.sqrt(2*numerix.pi*2*dz)) return 22 * numerix.exp(-r**2 / (2 * Ra)) / (numerix.sqrt(2 * numerix.pi * Ra))
elif (problem == "b"): print "Creating mesh for problem b" mesh = fp.Grid2D(nx=N, ny=N, dx=200.0/float(N), dy=200.0/float(N)) elif (problem == "c"): print "Creating mesh for problem c" # mesh = fp.Grid2D(dx=0.5, dy=0.5, nx=40, ny=200) + (fp.Grid2D(dx=0.5, dy=0.5, nx=200, ny=40) + [[-40],[100]]) mesh = fp.Grid2D(Lx=20., Ly=100.0, nx=N / 5, ny=N) + (fp.Grid2D(Ly=20.0, Lx=100.0, nx=N, ny=N / 5) + [[-40],[100]]) elif (problem == "d"): print "Creating mesh for problem da" r = float(sys.argv[2]) numCellsDesired = int(sys.argv[3]) epsilon = 0.05 cellSize = 16 * np.pi * r**2 / (nmx.sqrt(3.) * numCellsDesired) cellSize = nmx.sqrt(cellSize) substring1 = ''' radius = {0}; cellSize = {1}; '''.format(r, round(cellSize, 6)) mesh = fp.Gmsh2DIn3DSpace(substring1 + ''' // create inner 1/8 shell Point(1) = {0, 0, 0, cellSize}; Point(2) = {-radius, 0, 0, cellSize}; Point(3) = {0, radius, 0, cellSize}; Point(4) = {0, 0, radius, cellSize}; Circle(1) = {2, 1, 3};
def TwoSigmaF2D(x,y, Rs): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz**2))/(numerix.sqrt(dz**2)*numerix.sqrt(2*numerix.pi))) return ((200e-3+0.)*numerix.exp(-((x+0.6)**2 + (y-0.3)**2)/(2*Rs)) +(300e-3+0.)*numerix.exp(-((x-0.6)**2 + (y-0.2)**2)/(2*Rs)))/(numerix.sqrt(2*numerix.pi*Rs))
import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import fipy as fp from fipy import numerix as nmx r = 100 numCellsDesired = 2500 epsilon = 0.05 cellSize = 16 * np.pi * r**2 / (nmx.sqrt(3.) * numCellsDesired) cellSize = nmx.sqrt(cellSize) substring1 = ''' radius = {0}; cellSize = {1}; '''.format(r, round(cellSize, 6)) mesh = fp.Gmsh2DIn3DSpace(substring1 + ''' // create inner 1/8 shell Point(1) = {0, 0, 0, cellSize}; Point(2) = {-radius, 0, 0, cellSize}; Point(3) = {0, radius, 0, cellSize}; Point(4) = {0, 0, radius, cellSize}; Circle(1) = {2, 1, 3}; Circle(2) = {4, 1, 2}; Circle(3) = {4, 1, 3}; Line Loop(1) = {1, -3, 2}; Ruled Surface(1) = {1};
def GaussianImmuneResponse2D(strength, x, y, Ra): #Test : plt.plot(r,10*numerix.exp(-r**2/(2*dz))/numerix.sqrt(2*numerix.pi*2*dz)) return strength * numerix.exp(-( (x**2) + (y**2)) / (2 * Ra)) / (numerix.sqrt(2 * numerix.pi * Ra))