BBL736 Assignment
BBL736 Assignment
Ravinder 2021BB10008
Shashank 2021BB10362
Pankaj Kumar 2021BB10350
Question 1:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
# Parameters
alpha = 10
n = 2
# Plotting results
plt.figure(figsize=(10, 5))
# Plot case 1
plt.plot(sol1.t, sol1.y[0], label='p1 (IC: 5,1)', color='blue')
plt.plot(sol1.t, sol1.y[1], label='p2 (IC: 5,1)', color='red', linestyle='--')
# Plot case 2
plt.plot(sol2.t, sol2.y[0], label='p1 (IC: 1,5)', color='green')
plt.plot(sol2.t, sol2.y[1], label='p2 (IC: 1,5)', color='orange', linestyle='--')
plt.xlabel('Time')
plt.ylabel('Protein concentration')
plt.title('Time series for the mutual repressor system')
plt.legend()
plt.show()
dt = 0.05
t_euler = np.arange(t_span[0], t_span[1] + dt, dt)
plt.figure(figsize=(10, 5))
# Case 1 Euler
plt.plot(t_euler, p_euler1[:, 0], label='p1 Euler (IC: 5,1)', color='blue')
plt.plot(t_euler, p_euler1[:, 1], label='p2 Euler (IC: 5,1)', color='red',
linestyle='--')
# Case 2 Euler
plt.plot(t_euler, p_euler2[:, 0], label='p1 Euler (IC: 1,5)', color='green')
plt.plot(t_euler, p_euler2[:, 1], label='p2 Euler (IC: 1,5)', color='orange',
linestyle='--')
plt.xlabel('Time')
plt.ylabel('Protein concentration')
plt.title('Time series using Euler method')
plt.legend()
plt.show()
plt.figure(figsize=(10, 5))
# Case 1 RK4
plt.plot(t_euler, p_rk4_1[:, 0], label='p1 RK4 (IC: 5,1)', color='blue')
plt.plot(t_euler, p_rk4_1[:, 1], label='p2 RK4 (IC: 5,1)', color='red',
linestyle='--')
# Case 2 RK4
plt.plot(t_euler, p_rk4_2[:, 0], label='p1 RK4 (IC: 1,5)', color='green')
plt.plot(t_euler, p_rk4_2[:, 1], label='p2 RK4 (IC: 1,5)', color='orange',
linestyle='--')
plt.xlabel('Time')
plt.ylabel('Protein concentration')
plt.title('Time series using RK4 method')
plt.legend()
plt.show()
Question 2:
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
# PARAMETERS
alpha = 10
n = 2
max_time = 50
if a0 == 0:
break
times.append(t)
NP1_list.append(NP1)
NP2_list.append(NP2)
plt.figure(figsize=(12, 6))
plt.plot(sol_det1.t, sol_det1.y[0], label='Deterministic p1 (IC: 5,1)', color='blue',
linewidth=2)
plt.plot(sol_det1.t, sol_det1.y[1], label='Deterministic p2 (IC: 5,1)', color='red',
linewidth=2, linestyle='--')
# Case 2: Deterministic
plt.plot(sol_det2.t, sol_det2.y[0], label='Deterministic p1 (IC: 1,5)', color='green',
linewidth=2)
plt.plot(sol_det2.t, sol_det2.y[1], label='Deterministic p2 (IC: 1,5)',
color='orange', linewidth=2, linestyle='--')
plt.xlabel('Time')
plt.ylabel('Protein number / concentration')
plt.title('Deterministic vs Stochastic (Gillespie) Simulations of the Mutual Repressor
System')
plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left')
plt.tight_layout()
plt.show()