{"id":1582,"date":"2021-08-27T23:30:00","date_gmt":"2021-08-28T03:30:00","guid":{"rendered":"http:\/\/underthehood.blogwyrm.com\/?p=1582"},"modified":"2022-07-28T06:28:23","modified_gmt":"2022-07-28T10:28:23","slug":"a-binomial-gas","status":"publish","type":"post","link":"https:\/\/underthehood.blogwyrm.com\/?p=1582","title":{"rendered":"A Binomial Gas"},"content":{"rendered":"\n<p>The last installment discussed Robert Swendsen\u2019s critique of the common, and in his analysis, erroneous method of understanding the entropy of a classical gas of distinguishable particles.&nbsp; As discussed in that post, his aim in making this analysis is to persuade the physics community to re-examine its understanding of entropy and to rediscover Boltzmann\u2019s fundamental definition based on probability and not on phase space volume.&nbsp; To quote some of Swendsen closing words:<\/p>\n\n\n\n<div class=\"myQuoteDiv\">\nAlthough the identification of the entropy with the logarithm of a volume in phase space did originate with Boltzmann, it was only a special case. Boltzmann\u2019s fundamental definition of the entropy in his 1877 paper has none of the shortcomings resulting from applying an equation for a special case beyond its range of validity.\n<\/div>\n\n\n\n<p>On the question of how this special case blossomed into textbook dogma we will have to content ourselves with speculations.&nbsp; It seems likely that the passion by which quantum mechanics gripped the physics community made it attractive to view the entire world through the lens of indistinguishable particles.&nbsp; Furthermore, quantum mechanics also elevated the concept of phase space since various dimensions could be viewed as canonically conjugate variables subject to the uncertainty principle.&nbsp; So, it is plausible that the physics community, dazzled by this new theory of the subatomic, latched onto the special case and ignored Boltzmann\u2019s fundamental definition.&nbsp; If true, this would be incredibly ironic since the key focus of Boltzmann was on probability which is arguably the most shocking and intriguing aspect of quantum mechanics.<\/p>\n\n\n\n<p>Regardless of these finer points of physics history, since the concept of probability is key in deriving the correct formula for a classical distinguishable gas let\u2019s focus on the toy example Swendsen provides in order to illustrate his point.&nbsp; As in the last post, we will assume that the average energy per particle $\n\n\n\n<p>If we imagine a system with $N$ total distinguishable particles distributed between a volume $V$ partitioned into sub-volumes $V_1$ and $V_2$ then the probability $P(N_1,N_2)$ of having $N_1$ particles in $V_1$ and $N_2 = N &#8211; N_1$ in $V_2 = V &#8211; V_1$ is given by the binomial distribution<\/p>\n\n\n\n<p>\\[ P(N_1,N_2) = \\left( \\begin{array}{c} N \\\\ N_1 \\end{array} \\right) p^{N_1} (1-p)^{N_2} \\; ,\\]<\/p>\n\n\n\n<p>where \u00a0$p$ is the probability of being found in $V_1$ (i.e. a \u2018success\u2019).\u00a0 Since there are no constraints forcing particles to accumulate in any one section compared to the others they will distribute randomly within the entire domain.\u00a0 Therefore, $p = V_1\/V$ and the probability is given by<\/p>\n\n\n\n<p>\\[ P(N_1,N_2) = \\left( \\frac{N!}{N_1! N_2!} \\right) \\left( \\frac{V_1}{V} \\right)^{N_1} \\left( \\frac{V_2}{V} \\right)^{N_2} \\; .\\]<\/p>\n\n\n\n<p>This expression is Swendsen\u2019s launching point for deriving the correct expression for a classical gas of distinguishable particles.&nbsp; But before continuing with the analysis it is worth taking a few moments to better understand the physical content of that expression (even for those you understand the binomial distribution well).&nbsp;<\/p>\n\n\n\n<p>There is a very compact way to make a Monte Carlo simulation of this thought experiment using the python ecosystem. \u00a0One starts by defining a random realization of the classical gas particles placed within the volume and then reporting out the macroscopic thermodynamic state.\u00a0<\/p>\n\n\n\n<div class=\"myQuoteDiv\">\n<pre>\ndef particles_in_a_box(V1,N,V):\n    import numpy as np\n\n    #get random positions of the particles\n    pos = np.random.random(N)\n\n    #count number in subvolume V1\n    threshold = V1\/V\n    return len(np.where(pos&lt;threshold)[0])\n<\/pre>\n<\/div>\n\n\n\n<p>In this context, the macroscopic thermodynamic state is a measure of how many particles are found in the sub-volume $V_1$.\u00a0 This is a critical point, particularly in light of the quantum interpretation that so many have embraced: two thermodynamic states can be identical without the underlying microstates being the same.\u00a0 For example, if $N=3$ and $N_1=2$ then each of the following lists results in the same thermodynamic state:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>[True,True,False]<\/li><li>[True,False,True]<\/li><li>[False,True,True]<\/li><\/ul>\n\n\n\n<p>where True and False result from the call to the numpy.where function and indicate whether the particle is found within $V_1$ (True) or not (False).<\/p>\n\n\n\n<p>To get the probabilities, one makes an ensemble of such systems and this is what the following function does<\/p>\n\n\n\n<div class=\"myQuoteDiv\">\n<pre>\ndef generate_MC_estimate(V1,N,V,num_trials):\n    import numpy as np\n    results = np.zeros(num_trials)\n    for i in range(num_trials):\n        results[i] = particles_in_a_box(V1,N,V)\n    return results\n<\/pre>\n<\/div>\n\n\n\n<p>The following plot shows how well the empirical results for an ensemble with 100,000 realizations agree with the formula derived above for a simulation of 2000 particles placed in a box where $V_1 = 0.3 V$.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"432\" height=\"288\" src=\"http:\/\/underthehood.blogwyrm.com\/wp-content\/uploads\/2021\/08\/Binomial_Gas.png\" alt=\"\" class=\"wp-image-1581\" srcset=\"https:\/\/underthehood.blogwyrm.com\/wp-content\/uploads\/2021\/08\/Binomial_Gas.png 432w, https:\/\/underthehood.blogwyrm.com\/wp-content\/uploads\/2021\/08\/Binomial_Gas-300x200.png 300w, https:\/\/underthehood.blogwyrm.com\/wp-content\/uploads\/2021\/08\/Binomial_Gas-320x213.png 320w, https:\/\/underthehood.blogwyrm.com\/wp-content\/uploads\/2021\/08\/Binomial_Gas-146x97.png 146w, https:\/\/underthehood.blogwyrm.com\/wp-content\/uploads\/2021\/08\/Binomial_Gas-250x167.png 250w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/figure>\n\n\n\n<p>Following Boltzmann, the entropy is<\/p>\n\n\n\n<p>\\[ S = k \\ln P + C =  k \\ln \\left[ \\left( \\frac{N!}{V^{N_1}V^{N_2}}\\right) \\left( \\frac{{V_1}^{N_1}}{N_1 !} \\right) \\left( \\frac{{V_2}^{N_2}}{N_2 !} \\right)  + C \\right] \\; ,\\]<\/p>\n\n\n\n<p>where the previous expression has been grouped into parts dealing with the entire subsystem $(N,V)$, the first sub-volume $(N_1,V_1)$, and the second subsystem $(N_2,V_2)$.\u00a0 The constant $C$ depends only the whole system $N$ and $V$ but not on the subdivisions and, for reasons that should become obvious, we will take it to be<\/p>\n\n\n\n<p>\\[ C = &#8211; k \\ln \\left( \\frac{{V}^{N}}{N !} \\right) \\; . \\]<\/p>\n\n\n\n<p>We first expand the entropy expression along this grouping to get<\/p>\n\n\n\n<p>\\[ S = k \\ln \\left( \\frac{N!}{{V}^{N}} \\right) + k \\ln \\left( \\frac{{V_1}^{N_1}}{N_1 !} \\right) + k \\ln \\left( \\frac{{V_2}^{N_2}}{N_2 !} \\right) &#8211; &nbsp;k \\ln \\left( \\frac{{V}^{N}}{N !} \\right) \\; .\\]<\/p>\n\n\n\n<p>The first and last terms are inverses of each other and, under the action of the logarithm, cancel, leaving<\/p>\n\n\n\n<p>\\[ S = k \\ln \\left( \\frac{{V_1}^{N_1}}{N_1 !} \\right) + k \\ln \\left( \\frac{{V_2}^{N_2}}{N_2 !} \\right) \\; .\\]<\/p>\n\n\n\n<p>As the whole is a sum of the parts, this expression is clearly extensive.<\/p>\n\n\n\n<p>The final step is the application of Sterlings approximation ($\\ln n! \\approx \u00a0n \\ln n \u2013 n$).\u00a0 To keep things clear, we will apply it to terms of the form<\/p>\n\n\n\n<p>\\[ S = k \\ln \\left( \\frac{V^N}{N!} \\right) \\; \\]<\/p>\n\n\n\n<p>to get<\/p>\n\n\n\n<p>\\[ S = k \\left( \\ln V^N &#8211; \\ln N! \\right) = k \\left( N \\ln V &#8211; N \\ln N &#8211; N \\right) = k N \\left( \\ln \\frac{V}{N} &#8211; 1 \\right)  \\;  ,  \\]<\/p>\n\n\n\n<p>which clearly shows that $S$ scales linearly with the system size (at least in the thermodynamic limit).<\/p>\n\n\n\n<p>All told, Swendsen argues persuasively that the correct interpretation of the entropy is that it is always proportional to the logarithm of the probability, that the \u2018traditional\u2019 expression depending on the volume of phase is a special case of the larger rule, and that by misapplying this special case large numbers of physicists have taught or have been taught incorrectly for decades.&nbsp; So much for the ideas of settled science.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The last installment discussed Robert Swendsen\u2019s critique of the common, and in his analysis, erroneous method of understanding the entropy of a classical gas of distinguishable particles.&nbsp; As discussed in&#8230; <a class=\"read-more-button\" href=\"https:\/\/underthehood.blogwyrm.com\/?p=1582\">Read more &gt;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1582","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1582"}],"version-history":[{"count":20,"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1582\/revisions"}],"predecessor-version":[{"id":1603,"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1582\/revisions\/1603"}],"wp:attachment":[{"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underthehood.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}