.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/polymer/chain_statistics/plot_01_chain_scaling.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_polymer_chain_statistics_plot_01_chain_scaling.py: Flory's solvent-quality exponents: ideal vs. real chain scaling =================================================================== Flory's mean-field argument (*Principles of Polymer Chemistry*, 1953) predicts how excluded volume changes a chain's size scaling. :class:`~chemistrykit.polymer.systems.chain_statistics.IdealChain` gives the *exact* random-walk result :math:`\langle R^2\rangle=nb^2`. :class:`~chemistrykit.polymer.systems.chain_statistics.RealChain` scales instead as :math:`R\sim bn^\nu`, with the Flory exponent :math:`\nu` set by solvent quality: a good solvent swells the chain (:math:`\nu\approx0.6`), a poor solvent collapses it (:math:`\nu=1/3`), and the theta solvent reproduces the ideal chain exactly (:math:`\nu=1/2`). .. GENERATED FROM PYTHON SOURCE LINES 18-34 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.polymer.systems.chain_statistics import IdealChain, RealChain, flory_exponent from chemistrykit.polymer.visualizers.polymer_plots import plot_chain_scaling b = 0.5 # segment length n_values = np.logspace(1, 5, 30) ideal = IdealChain() theta = RealChain.theta_solvent() good = RealChain.good_solvent() poor = RealChain.poor_solvent() print(f"Flory exponents: theta={flory_exponent('theta')}, good={flory_exponent('good'):.4f}, poor={flory_exponent('poor'):.4f}") .. rst-class:: sphx-glr-script-out .. code-block:: none Flory exponents: theta=0.5, good=0.6000, poor=0.3333 .. GENERATED FROM PYTHON SOURCE LINES 35-36 The ideal chain's scales exactly linearly with n. .. GENERATED FROM PYTHON SOURCE LINES 36-45 .. code-block:: Python n1, n2 = 1000.0, 4000.0 ratio = ideal.mean_square_end_to_end(n2, b) / ideal.mean_square_end_to_end(n1, b) print(f"\n(4000) / (1000) for the ideal chain: {ratio:.6f} (exactly 4.0)") # theta-solvent RealChain reproduces the ideal chain's end-to-end distance exactly. n_test = 5000.0 match = np.isclose(theta.end_to_end_distance(n_test, b), ideal.end_to_end_distance(n_test, b)) print(f"theta-solvent RealChain matches IdealChain exactly: {bool(match)}") .. rst-class:: sphx-glr-script-out .. code-block:: none (4000) / (1000) for the ideal chain: 4.000000 (exactly 4.0) theta-solvent RealChain matches IdealChain exactly: True .. GENERATED FROM PYTHON SOURCE LINES 46-48 A good solvent swells the chain; a poor solvent collapses it, relative to the ideal chain of the same length. .. GENERATED FROM PYTHON SOURCE LINES 48-54 .. code-block:: Python n_test = 10000.0 print(f"\nAt n={n_test:.0f}, b={b}:") print(f" ideal chain R = {ideal.end_to_end_distance(n_test, b):.2f}") print(f" good-solvent R = {good.end_to_end_distance(n_test, b):.2f} (swollen)") print(f" poor-solvent R = {poor.end_to_end_distance(n_test, b):.2f} (collapsed)") .. rst-class:: sphx-glr-script-out .. code-block:: none At n=10000, b=0.5: ideal chain R = 50.00 good-solvent R = 125.59 (swollen) poor-solvent R = 10.77 (collapsed) .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python models = {"ideal (theta)": ideal, "good solvent": good, "poor solvent": poor} ax = plot_chain_scaling(models, n_values, b) plt.tight_layout() plt.show() .. image-sg:: /api/gallery/polymer/chain_statistics/images/sphx_glr_plot_01_chain_scaling_001.png :alt: Chain-size scaling :srcset: /api/gallery/polymer/chain_statistics/images/sphx_glr_plot_01_chain_scaling_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.068 seconds) .. _sphx_glr_download_api_gallery_polymer_chain_statistics_plot_01_chain_scaling.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_chain_scaling.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_chain_scaling.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_chain_scaling.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_