<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://fbswiki.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Figure_5.15%3A_Stability_of_a_genetic_switch</id>
	<title>Figure 5.15: Stability of a genetic switch - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://fbswiki.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Figure_5.15%3A_Stability_of_a_genetic_switch"/>
	<link rel="alternate" type="text/html" href="http://fbswiki.org/wiki/index.php?title=Figure_5.15:_Stability_of_a_genetic_switch&amp;action=history"/>
	<updated>2026-04-24T21:52:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>http://fbswiki.org/wiki/index.php?title=Figure_5.15:_Stability_of_a_genetic_switch&amp;diff=1289&amp;oldid=prev</id>
		<title>Murray: Created page with &quot;{{Figure |Chapter=Dynamic Behavior |Figure number=5.15 |Sort key=515 |Figure title=Stability of a genetic switch |GitHub URL=https://github.com/murrayrm/fbs2e-python/blob/main...&quot;</title>
		<link rel="alternate" type="text/html" href="http://fbswiki.org/wiki/index.php?title=Figure_5.15:_Stability_of_a_genetic_switch&amp;diff=1289&amp;oldid=prev"/>
		<updated>2024-11-18T02:09:26Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Figure |Chapter=Dynamic Behavior |Figure number=5.15 |Sort key=515 |Figure title=Stability of a genetic switch |GitHub URL=https://github.com/murrayrm/fbs2e-python/blob/main...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Figure&lt;br /&gt;
|Chapter=Dynamic Behavior&lt;br /&gt;
|Figure number=5.15&lt;br /&gt;
|Sort key=515&lt;br /&gt;
|Figure title=Stability of a genetic switch&lt;br /&gt;
|GitHub URL=https://github.com/murrayrm/fbs2e-python/blob/main/example-5.13-genetic_switch.py&lt;br /&gt;
}}&lt;br /&gt;
[[Image:figure-5-15-genswitch_stability.png]]&lt;br /&gt;
&lt;br /&gt;
'''Figure 5.15''': Stability of a genetic switch. The circuit diagram in (a) [not shown here] represents two proteins that are each repressing the production of the other. The inputs u1 and u2 interfere with this repression, allowing the circuit dynamics to be modified. The equilibrium points for this circuit can be determined by the intersection of the two curves shown in (b).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
# example-5.13-genetic_switch.py - Genetic switch dynamics&lt;br /&gt;
# RMM, 17 Nov 2024&lt;br /&gt;
#&lt;br /&gt;
# Figure 5.15: Stability of a genetic switch. The circuit diagram in (a)&lt;br /&gt;
# represents two proteins that are each repressing the production of the&lt;br /&gt;
# other. The inputs u1 and u2 interfere with this repression, allowing the&lt;br /&gt;
# circuit dynamics to be modified. The equilibrium points for this circuit&lt;br /&gt;
# can be determined by the intersection of the two curves shown in (b).&lt;br /&gt;
#&lt;br /&gt;
# Figure 5.16: Dynamics of a genetic switch. The phase portrait on the left&lt;br /&gt;
# shows that the switch has three equilibrium points, corresponding to&lt;br /&gt;
# protein A having a concentration greater than, equal to, or less than&lt;br /&gt;
# protein B. The equilibrium point with equal protein concentrations is&lt;br /&gt;
# unstable, but the other equilibrium points are stable. The simulation on&lt;br /&gt;
# the right shows the time response of the system starting from two&lt;br /&gt;
# different initial conditions. The initial portion of the curve&lt;br /&gt;
# corresponds to initial concentrations z(0) = (1, 5) and converges to the&lt;br /&gt;
# equilibrium point where z1e &amp;lt; z2e. At time t = 10, the concentrations are&lt;br /&gt;
# perturbed by +2 in z1 and −2 in z2, moving the state into the region of&lt;br /&gt;
# the state space whose solutions converge to the equilibrium point where&lt;br /&gt;
# z2e &amp;lt; z1e.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import control as ct&lt;br /&gt;
import numpy as np&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
from scipy.integrate import solve_ivp&lt;br /&gt;
from scipy.optimize import fsolve&lt;br /&gt;
ct.use_fbs_defaults()&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# System dynamics&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Switch parameters&lt;br /&gt;
genswitch_params = {'mu': 4, 'n': 2}&lt;br /&gt;
&lt;br /&gt;
def genswitch_dynamics(t, x, u, params):&lt;br /&gt;
    mu = params.get('mu')&lt;br /&gt;
    n = params.get('n')&lt;br /&gt;
    z1, z2 = x&lt;br /&gt;
    dz1 = mu / (1 + z2**n) - z1&lt;br /&gt;
    dz2 = mu / (1 + z1**n) - z2&lt;br /&gt;
    return [dz1, dz2]&lt;br /&gt;
&lt;br /&gt;
genswitch_model = ct.nlsys(&lt;br /&gt;
    genswitch_dynamics, None, states=2, inputs=None, params=genswitch_params)&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# 5.15 (b) Equilibrium points&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Set up the plotting grid to match the layout in the book&lt;br /&gt;
fig = plt.figure(constrained_layout=True)&lt;br /&gt;
gs = fig.add_gridspec(2, 2)&lt;br /&gt;
ax = fig.add_subplot(gs[0, 1])&lt;br /&gt;
&lt;br /&gt;
# Generate nullcline&lt;br /&gt;
mu, n = genswitch_params['mu'], genswitch_params['n']&lt;br /&gt;
u = np.linspace(0, 5, 100)&lt;br /&gt;
f = mu / (1 + u**n)&lt;br /&gt;
&lt;br /&gt;
# Find equilibrium points&lt;br /&gt;
def eq_func(z):&lt;br /&gt;
    return mu / (1 + z**2) - z&lt;br /&gt;
&lt;br /&gt;
eqpts = [fsolve(eq_func, 2)[0], fsolve(eq_func, 0)[0], fsolve(eq_func, -2)[0]]&lt;br /&gt;
&lt;br /&gt;
ax.plot(u, f, 'b-', label='$z_1, f(z_1)$')&lt;br /&gt;
ax.plot(f, u, 'r--', label='$z_2, f(z_2)$')&lt;br /&gt;
ax.plot([0, 3], [0, 3], 'k-', linewidth=0.5)&lt;br /&gt;
ax.scatter(eqpts, eqpts[::-1], color='k')&lt;br /&gt;
ax.axis([0, 5, 0, 5])&lt;br /&gt;
ax.set_xlabel('$z_1, f(z_2)$')&lt;br /&gt;
ax.set_ylabel('$z_2, f(z_1)$')&lt;br /&gt;
ax.legend()&lt;br /&gt;
ax.set_title('(b) Equilibrium Curves')&lt;br /&gt;
&lt;br /&gt;
# Save the first figure&lt;br /&gt;
plt.savefig(&amp;quot;figure-5.15-genswitch_nullclines.png&amp;quot;, bbox_inches='tight')&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Murray</name></author>
	</entry>
</feed>