.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/polymer/step_growth/plot_01_carothers.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_step_growth_plot_01_carothers.py: The Carothers equation ========================= Step-growth polymerization's number-average degree of polymerization follows the Carothers equation :math:`\bar X_n=1/(1-p)`, which diverges as the extent of reaction `p` approaches 1 -- reaching a useful high molecular weight requires very high conversion. A stoichiometric imbalance between the two functional groups caps :math:`\bar X_n` even at complete conversion of the limiting group. .. GENERATED FROM PYTHON SOURCE LINES 14-27 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.polymer.systems.step_growth import ( degree_of_polymerization, degree_of_polymerization_stoichiometric_imbalance, extent_of_reaction_for_DP, ) from chemistrykit.polymer.visualizers.polymer_plots import plot_carothers_curve for p in (0.5, 0.9, 0.95, 0.99, 0.999): print(f"p = {p:<6} -> Xn = {degree_of_polymerization(p):8.2f}") .. rst-class:: sphx-glr-script-out .. code-block:: none p = 0.5 -> Xn = 2.00 p = 0.9 -> Xn = 10.00 p = 0.95 -> Xn = 20.00 p = 0.99 -> Xn = 100.00 p = 0.999 -> Xn = 1000.00 .. GENERATED FROM PYTHON SOURCE LINES 28-29 Reaching a modest Xn=100 requires 99% conversion, not 90%. .. GENERATED FROM PYTHON SOURCE LINES 29-32 .. code-block:: Python p_for_100 = extent_of_reaction_for_DP(100.0) print(f"\nExtent of reaction needed for Xn=100: p = {p_for_100:.4f}") .. rst-class:: sphx-glr-script-out .. code-block:: none Extent of reaction needed for Xn=100: p = 0.9900 .. GENERATED FROM PYTHON SOURCE LINES 33-34 A stoichiometric imbalance (r < 1) caps the attainable Xn even as p -> 1. .. GENERATED FROM PYTHON SOURCE LINES 34-42 .. code-block:: Python p_scan = np.linspace(0.0, 0.999, 300) Xn_balanced = degree_of_polymerization(p_scan) Xn_imbalanced = degree_of_polymerization_stoichiometric_imbalance(p_scan, r=0.98) Xn_balanced_at_p999 = degree_of_polymerization(0.999) Xn_imbalanced_at_p999 = degree_of_polymerization_stoichiometric_imbalance(0.999, r=0.98) print(f"\nAt p=0.999: Xn (balanced) = {Xn_balanced_at_p999:.1f}, Xn (r=0.98) = {Xn_imbalanced_at_p999:.1f}") .. rst-class:: sphx-glr-script-out .. code-block:: none At p=0.999: Xn (balanced) = 1000.0, Xn (r=0.98) = 90.2 .. GENERATED FROM PYTHON SOURCE LINES 43-50 .. code-block:: Python fig, ax = plt.subplots() plot_carothers_curve(p_scan, Xn_balanced, ax=ax, label="stoichiometric balance (r=1)") plot_carothers_curve(p_scan, Xn_imbalanced, ax=ax, linestyle="--", label="r=0.98 (stoichiometric imbalance)") ax.set_ylim(0, 250) ax.legend() plt.tight_layout() plt.show() .. image-sg:: /api/gallery/polymer/step_growth/images/sphx_glr_plot_01_carothers_001.png :alt: Carothers equation :srcset: /api/gallery/polymer/step_growth/images/sphx_glr_plot_01_carothers_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.036 seconds) .. _sphx_glr_download_api_gallery_polymer_step_growth_plot_01_carothers.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_carothers.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_carothers.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_carothers.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_