simple_model_optimize.py
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def model(N, A):
mr = 0.161 * 0.784 * N / 2.657
pr = 0.36 * mr / 2.658
mb = (1.13E-16 + 5.269 * 0.784 * N * (0.696 * A * pr)**2 / (1 + (0.696 * A * pr)**2)) / 0.231
pb = 2.297 * mb / 0.181
return pb
x_new = np.arange(0, 35, 1)
y_new = np.arange(0, 50, 0.01)
G = np.arange(1000, 3000, 100)
xx = []
yy = []
index = -1
for g in G:
xx.append([])
yy.append([])
index += 1
for i in x_new:
for j in y_new:
if(model(i, j) > g):
xx[index].append(i)
yy[index].append(j)
break
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for i in range(len(G)):
x = xx[i]
y = [G[i] for j in range(len(x))]
z = yy[i]
ax.plot(x, y, z, color='blue')
#ax.plot_surface(x_new, y_new, z_new, cmap='rainbow', label = "simulated distribution")
ax.set_xlabel("DNA($ng/uL)$")
ax.set_ylabel("GFP($ng/ul$)")
ax.set_zlabel("AHL($nM$)")
ax.grid(True)
plt.show()