posts:one-off-git-daemon: Add a git://192.168.1.2/ example
[blog.git] / posts / Comparing_velocity_clamp_experiments / frc.py
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2012  W. Trevor King <wking@tremily.us>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 """Freely rotating chain (FRC) following Livadaru et al. [1].
19
20 [1]: http://pubs.acs.org/doi/abs/10.1021/ma020751g
21 """
22
23 import numpy as _numpy
24 import matplotlib.pyplot as _pyplot
25 try:  # SciPy >= 0.10.0
26     from scipy.constants import Boltzmann as _kB
27 except ImportError:  # SciPy < 0.10.0
28     from scipy.constants import Bolzmann as _kB
29
30 from crunch import inverse_frc
31
32
33 def figure_14():
34     figure = _pyplot.figure()
35     axes = figure.add_subplot(1, 1, 1)
36     axes.set_xscale('log')
37     axes.set_yscale('log')
38     axes.hold(True)
39     Fs = 10**_numpy.linspace(-4, 2.2, 100)
40     for gamma_degrees in [1, 5, 10, 20, 30, 50, 70]:
41         gamma = gamma_degrees * _numpy.pi / 180
42         xs = _numpy.array([inverse_frc(F, gamma) for F in Fs])
43         axes.plot(Fs, 1/(1-xs))
44     axes.axis([Fs.min(), Fs.max(), 0.9, 500])
45     axes.set_title('FRC force extension')
46     axes.set_xlabel(r'$\frac{fb}{k_B T}$')
47     axes.set_ylabel(r'$\left(1-\frac{R_z}{L}\right)^{-1}$')
48     figure.subplots_adjust(bottom=0.13)
49     return figure
50
51
52 if __name__ == '__main__':
53     figure = figure_14()
54     figure.savefig('figure-14.png')
55     #_pyplot.show()