{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 13 Line integrals"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# import all python add-ons etc that will be needed later on\n",
"%matplotlib inline\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from sympy import *\n",
"init_printing() # allows printing of SymPy results\n",
"plt.rcParams.update({'font.size': 16}) # set font size for plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 13 Introduction \n",
"The integrals so far studied have the form $\\displaystyle \\int f(x)dx$, which means that integration proceeds uniformly along the x-axis. Now suppose instead that we wish to integrate along some other direction, such as any curved line that is in the $x-y$ plane. This is not as obscure as it may sound. When you ride a bike, the force needed to keep you moving will obviously vary depending on which way or how fast you want to go. Similarly, the amount of energy you consume getting from one place to another depends on the path taken such as walking around a hill instead of over the top. In thermodynamics, line or path integrals are very important and explain why some integrals are represented as the difference between starting and ending values while other integrals have to be evaluated explicitly.\n",
"\n",
"Three things are needed to calculate a line integral: \n",
"\n",
"**(a)** The path to be followed, $C$.\n",
"\n",
"**(b)** Its starting and ending points, $A$ and $B$. \n",
"\n",
"**(c)** The 'line' or surface function itself, $P(x, y)$.\n",
"\n",
"The line is often a two-dimensional function of $x$ and $y$. A typical example would be to calculate the line integral of $P(x, y) = x + y$ along a path or curve given by $y = x^2/2$ from $x = 0 \\to = 2$. This is written in the form\n",
"\n",
"$$\\displaystyle \\int_C (x+y)dx\\quad\\text{ where the path }\\quad C \\text{ is } y=x^2/2\\quad \\text{ and the limits } \\quad x=0,2$$\n",
"\n",
"The $C$ subscript on the integral is the conventional notation to indicate a line integral, although, unfortunately, this is not usually used in thermodynamics. The integral $\\displaystyle \\int(x + y)dx$ cannot be evaluated as it stands, because we do not yet know how $y$ is related to $x$ and integration is with respect to $x$. The path taken determines the relationship between $y$ and $x$ and mathematically, this can take almost any form we choose. In practice, of course, the specific problem being studied will determine this relationship. Therefore integration of $\\displaystyle \\int(x+y)dx$ could just as easily be over the path $y=e^x$ from $x=-2\\to 2$ or $y=\\sin(3x)$ from $0 \\to \\pi/2$ and so forth and consequently there is no limit to the number of examples that can be devised even with a single surface.\n",
"\n",
"Figure 33 shows the path of a circle of radius 3 projected onto the surface $P(x, y) = x^3y+xy^3+50$. The line integral is the curtain-like area between the lower circle $C$ in the $x-y$ plane and its projection hugging the surface. If this seems rather esoteric, consider instead a prosaic example of finding the weight of a piece of wire. This is path $C$ (Figure 33). Now suppose that the wire has a weight that varies with its length and the weight changes as described by $P(x, y)$. The total weight must be the integral along the length of the string each little element of which is accounted for in proportion to $P$ by integrating. The weight at each point is the height of the line draped on $P$ above the $x-y$ plane as shown in Figure 33 and the whole weight is the area between curve $C$ in the $x-y$ plane and its projection on $P$. \n",
"\n",
"![Drawing](integration-fig33.png)\n",
"\n",
"Figure 33. The surface $P(x, y) = x^3y + xy^3 + 50$ with the curve (circle) $C$, $x^2 + y^2 = 3^2$. The red line is the path of the circle projected onto the surface; the circle is shown below in blue. The line integral is the yellow shaded curtain-like area shown between the circle and its projection onto the surface. \n",
"__________\n",
"Returning to the original example, to calculate the integral is easier than it may seem. All that is necessary is to substitute $y$ into the function $P = x + y$ and integrate as normal. If the path $C$ is $y = x^2/2$ then\n",
"\n",
"$$\\displaystyle \\int_C (x+y)dx=\\int_0^2(x+\\frac{x^2}{2})dx=\\frac{10}{3}$$\n",
"\n",
"and if path $C$ is $y=e^x$ from $x=-2\\to 2$ then $\\displaystyle \\int_C (x+y)dx=\\int_{-2}^2(x+e^x)dx=e^2+\\frac{1}{e^2}$.\n",
"\n",
"More formally, the line $P(x, y)$ is defined to be a surface or function of $x$ and $y$, and assumed to be single valued. $C$ is the curve in the plane defined as $y = f(x)$ going from points $A = (x_1, y_1)$ to $B = (x_2, y_2)$ as sketched in Figure 34. The integral could therefore be written as\n",
"\n",
"$$\\displaystyle \\int_C P(x,y)dx= \\int_{x_1}^{x_2} P\\big( x,f(x)\\,\\big) dx \\qquad\\tag{77}$$\n",
"\n",
"which does make the integral look rather ordinary.\n",
"\n",
"## 13.1 Definitions of some different forms of line integrals \n",
"\n",
"### **(i) Normal, i.e. continuous and single valued functions**\n",
"\n",
"The line integral of a surface $P(x, y)$ with curve $C \\equiv f(x)$ and limits $x_1 \\to x_2$ is\n",
"\n",
"$$\\displaystyle \\int_C P(x,y)dx = \\int_{x_1}^{x_2} P\\big( x,f(x)\\,\\big) dx \\qquad\\tag{78}$$\n",
"\n",
"A similar integral could be defined in terms of an integral in $y$ instead of x; for example, if $Q(x, y)$ is the line, then\n",
"\n",
"\n",
"$$\\displaystyle \\int_C Q(x,y)dy = \\int_{x_1}^{x_2} Q\\big( x,f(x)\\,\\big) \\frac{dy}{dx}dx \\qquad\\tag{79}$$\n",
"\n",
"but note that it is necessary to multiply by $dy/dx$ and integrate in $dx$.\n",
"\n",
"### **(ii) Parametric forms**\n",
"\n",
"Parametric equations are very useful in defining complex curves; a circle of radius $2$ about the origin has the form $x^2 + y^2 = 2^2$ in Cartesian coordinates, and in parametric form, $x = 2\\cos(t), y = 2\\sin(t)$; see Section 6. A curve defined in parametric form is written as $(x(t), y(t))$. Integration is obtained by substituting equation 78 for $x$ and $y$ in terms of $t$ and integrating in $t$,\n",
"\n",
"$$\\displaystyle \\int_C P(x,y)dy = \\int_{x_1}^{x_2} P\\big( x(t),y(t)\\,\\big) \\frac{dx}{dt}dt \\qquad\\tag{80}$$\n",
"\n",
"If the line is again $x + y$ and the integration is around the circle $x = 2\\cos(t), y = 2\\sin(t)$, choosing limits from $0 \\to \\pi$ gives\n",
"\n",
"$$\\displaystyle \\int_C (x+y)dx=-4\\int_0^\\pi \\big(\\cos(t)+\\sin(t)\\big)\\sin(t)dt =-2\\pi$$\n",
"\n",
"Using Sympy to do the integral gives"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAFUAAAAVCAYAAAA3raI2AAAAOXRFWHRTb2Z0d2FyZ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fDKgd5fKhfRw35BOQdBA4AlybpNuuC9wFfCjpSIE1IFxxbYDFcY+nkTyp7xJCfovt2cCnwCpJe4soT2JjnkSzE7g1SZBUkiFXDI3iWKjsak84GJuK6NoHNEnRehHyQMHQtz0ceIqQsPun+adPqqSJhLDZQSg35gF7bK+w3bGIgTkcyEM/TvV0b7lsXzeLGUOyLbBF0tEiuuol9OXQj3AFLso3yfbjhPJvCyG57kvLnLVRSe9I6kw4Eb2Btwj3zlLbVxUx8kIgd9c3ysNvTXB43tAHsF0LaJDQh+3awL3A8ng9ZM0bAbxKqGhKJe3OksusUyUdIGT+xdGAIQTnlmfJX0DsAvYSPsJkoV0cvy6ipyWhLNuYoHUjvKzM0Lc9inCPbgR6FcozyZKqNN0ZRFwdxz+LGPqvQ9IpQkHe2PYNGSK5E3yoiKrOcVyRoJUBJwll5Vmw/RzBoeuB24sl7uRJnQdU2F4DbCe8ya5Ap6hsWRFDLxTKCV3MncCPKV6uLR1nuw2hNPpW0nspuTsIte58gHiY+gKrJe1JCtoeCIyN8p8BwxMNRQ7bJb2d+5O8U58h1G/tCeXOYOASQodSGtvTiwHlhLtwQJohaSUwjODMYYA4cyUAYPtKggMXStoZyR2Bawi9fhot4lgbGBF1pp9ByQlV/vR3MSB+4B4PtJdU7P5Mzx0GvAJ0lfR5pI0nfCC6XtK287WvJj9Snw8mERqKsVWZZLsewXnlOYdGlAHfVIdD4T/q1Njt9AfWxda1smgOTCXVtUlqJaldddn3DwGqyR4VcSVQAAAAAElFTkSuQmCC\n",
"text/latex": [
"$\\displaystyle \\frac{\\sin^{2}{\\left(t \\right)}}{2}$"
],
"text/plain": [
" 2 \n",
"sin (t)\n",
"───────\n",
" 2 "
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t = symbols('t',positive=True)\n",
"eq = cos(t)*sin(t)\n",
"integrate(eq,t)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBOR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Ebgaj5/+DZicSATUsFLS/VkCtAjzgfVmtgRYiZ8URwAH4zz/sg1kmIdn547FEzQ1pOpZ0h+j8cfget3iAUtabmYXAHcCS81sAZ7Q6Y/zWwe0hb7PmtnvgF8Dr5vZ3LDe8Xhk4mng94npm9FbFt+ynLfiGzbdKVRge50nuqSngElBiEmA8CtnNPBj/P8FMYaEshdwcRgTf85KGddqXI7HZUfhCZSzgR3w7FybpK3CZy3APNx3nZCszNFzJ8ysL/6AF0paFU8s6W48I7oQd0suw9Phq4Hbor5TgNPwzTABf8nsCVyBX/UbEt2b0Vsq3zKcc/hWZntb/XsxRsisTQX2lhS/GHUjByExMw0YJanIJ0+OmwTcgieEnm6VfFWjar5V2l6ZPwy1A692G3lDuBFPLl1ddoCZ9cEf7rztycgDquZbme0VGrqkYZJGNrvQ/yNCFu9M4KWQJi+DwcBdeGp+u0LVfKu0vf8Ce9e3tBPvUykAAAAASUVORK5CYII=\n",
"text/latex": [
"$\\displaystyle \\frac{t}{2} - \\frac{\\sin{\\left(t \\right)} \\cos{\\left(t \\right)}}{2}$"
],
"text/plain": [
"t sin(t)⋅cos(t)\n",
"─ - ─────────────\n",
"2 2 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"eq = sin(t)**2\n",
"integrate(eq,t)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"![Drawing](integration-fig34-35.png) \n",
"\n",
"Figure 34 (Left) & 35. Right. A line integral is made along curve $C$. Right. Calculating a small length of a curve $\\delta s$.\n",
"_____\n",
"\n",
"## 13.3 Arc length on a surface $P(x,y)$\n",
"\n",
"Suppose that the length of a small section of the curve $C$ is $ds$ then a line integral can be defined in terms of this arc length. See the sketch, Fig. 4.35, \n",
"\n",
"$$\\displaystyle S= \\int_C P(x,y_ds= \\int_{x_1}^{x_2} P(x,y)\\frac{ds}{dx}dx \\qquad\\tag{81}$$\n",
"\n",
"By Pythagoras's theorem, $\\delta s^2 = \\delta x^2 + \\delta y^2$, rearranging and taking the limit to form the differential gives $\\displaystyle \\frac{ds}{dx}=\\sqrt{1+\\left( \\frac{dy}{dx} \\right)^2}$ which produces the result for the arc length $S$,\n",
"\n",
"$$\\displaystyle S=\\int_{x_1}^{x_2} P(x,y)\\sqrt{1+\\left( \\frac{dy}{dx} \\right)^2} dx \\qquad\\tag{82}$$\n",
"\n",
"where $y = f (x)$. \n",
"\n",
"Suppose that the surface is $P(x, y) = x + y$ then the arc length from $x = 0 \\to 4$ along a curve $C$ that we choose to be the parabola $y=1+x^2$ is \n",
"\n",
"$$\\displaystyle \\int_C (x+y)ds=\\int_{x_1}^{x_2}(x+y)\\frac{ds}{dx}dx=\\int_0^4(x+1+x^2)\\sqrt{1+4x^2}dx=190.36$$\n",
"\n",
"If the equation is in parametric form then $ds/dt$ is used instead of $ds/dx$ in equation 82 where $\\displaystyle \\frac{ds}{dt}=\\sqrt{\\left(\\frac{dx}{dt}\\right)^2 +\\left(\\frac{dy}{dt}\\right)^2}$.\n",
"\n",
"## 13.4 Length of a curve\n",
"\n",
"When only the length of a curve $C$ is required, all that is necessary is to make $P(x, y) = 1$ but still use the equation of the curve to define $dy/dx$;\n",
"\n",
"$$\\displaystyle S=\\int_C ds=\\int_{x_1}^{x_2} \\frac{ds}{dx}dx=\\int_{x_1}^{x_2} \\sqrt{1+\\left( \\frac{dy}{dx} \\right)^2} \\qquad\\tag{83}$$\n",
"\n",
"As an example, consider finding the length of the curve of the same parabola and limits as in Section 13.3. The integral is\n",
"\n",
"$$\\displaystyle S=\\int_C ds=\\int_{x_1}^{x_2} \\frac{ds}{dx}dx=\\int_0^4\\sqrt{1+4x^2}dx = \\frac{x\\sqrt{1+4x^2}}{2}+\\frac{1}{4}\\sinh^{-1}(2x)\\bigg|_0^4 \\approx 16.8$$\n",
"\n",
"If a curve is defined in plane polar coordinates, the arc length is\n",
"\n",
"$$\\displaystyle S=\\int_{x_1}^{x_2}\\sqrt{\\left(\\frac{dx}{d\\theta}\\right)^2 +\\left(\\frac{dy}{d\\theta}\\right)^2}d\\theta $$\n",
"\n",
"which after substituting for $x$ and $y$ becomes\n",
"\n",
"$$\\displaystyle S=\\int_{x_1}^{x_2}\\sqrt{ r^2 +\\left(\\frac{dr}{d\\theta}\\right)^2 } d\\theta \\qquad\\tag{84}$$\n",
"\n",
"The Archimedian spiral has the form $r=a\\theta$ where $a$ is a constant. The length of this curve is \n",
"\n",
"$$\\displaystyle \\int_0^\\theta \\sqrt{1+\\theta^2}d\\theta$$\n",
"\n",
"over angles $\\theta=0\\to\\theta$. Using Sympy produces $\\displaystyle S=\\frac{a}{2}\\left(\\theta\\sqrt{1+\\theta^2}+\\sinh^{-1}(\\theta)\\right)$"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPAAAAAeCAYAAAASG5NgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy89olMNAAAACXBIWXMAABJ0AAASdAHeZh94AAAJO0lEQVR4nO2dfbBVVRmHn4uIEmkGjuIwATIGUqSkUVqKICAVplyttCYUGpWJIbICgUbn5adk/qGCzQhqlBdU8iMCpitEgQZpfiQTmKLTh5BEYpJCg4UK3v5418Hdvnufez72OdwL+5lhFqzvc9b+rfWud619aGhpaSEnJ6dj0rkejUg6HHi7Hm11BMys4UD3IefgoC4CBkYBk8xsfp3ay8k5JOhUp3bGAA/Xqa2cnEOGegm4t5m9XKe2cnIOGWouYEkfBZ6vdTs5OYci9ViBc/M5J6dG1EPAZwK/q0M7OTmHHDX1Qkv6ALDbzPZlVN9M4CJgAPAW8CQw08yey6L+nJyORq1X4NHArzKsbxgwD/g0cC6wF1gtqXuGbeTkdBhqfQ78OeCaYhkkvQ+YCnwV6Au8BtwDmJm9E81rZqNjZccBu4DPAL/IrNc5OR2ERAGXI6o0JDUA3c3stSJ5TgBWAx8G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ScNTbowdF8L/ZNm5agknJ+uAYyWdFEurdrE5I4RR73em4x/1Qs/GHRBrJN0LdAO+DLRQmqiacdt+bVuNmtni4K2+Br+GuAN4EFDkOKK9M5jW5mO/8AfcIzo1mhge7LHAE2b2aiztctyHsA/fa05JcDhtiZuxdWAebio+JOln+N3dQbgX9UH8nDXKUmC3pCdx8Tfgjs0h+IO5uj7dLosl+E2n0cBfYmnV6OI8fDyXQ23Gf7+AMxDVKmCRmZX0+89mthB3qhwQwhfRVEX5WZR/9vwJ4EO4oynOiSE8DHf8JLGWKvpcCWb2rKTh+IM8Bn9mNuKT9U5aC3gGLoTTcBNzDz6ZTcdvbpX0NludWYLvhS8Dbo8mVKoL+Y9ZjAWazaxwRpz5+Dfk/zND/ZB0I355v5+ZbW4rf079kP/ay43AaWb2hwzq+yb+rsDZZvZYiMt8/Ov1s7I5TiOwMRdvu2QO/mbR9dVWFO5PzwSWFMQbyHz88xU4JycgaSgwHLg55VplqfUMxLcWTbV2yOYCzsnpwPwPMShCqgqkxhQAAAAASUVORK5CYII=\n",
"text/latex": [
"$\\displaystyle \\frac{\\theta \\sqrt{\\theta^{2} + 1}}{2} + \\frac{\\operatorname{asinh}{\\left(\\theta \\right)}}{2}$"
],
"text/plain": [
" ________ \n",
" ╱ 2 \n",
"θ⋅╲╱ θ + 1 asinh(θ)\n",
"───────────── + ────────\n",
" 2 2 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"theta = symbols('theta',positive=True)\n",
"eq = sqrt(1 + theta**2)\n",
"integrate(eq, theta )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 13.5 A surface defined by two functions\n",
"\n",
"Suppose that the surface is represented by two functions $M$ and $N$, which is often the case in thermodynamics, then the line integral can be written as two integrals in $dx$ and $dy$,\n",
"\n",
"$$\\displaystyle f=\\int_C M(x,y)dx+N(x,y)dy =\\int_C \\left(M(x,y)+N(x,y)\\frac{dy}{dx} \\right)dx \\qquad\\tag{85}$$\n",
"\n",
"As an example, the integral\n",
"\n",
"$$\\displaystyle \\int_C y^2 dx+2x^2y\\,dy \\qquad\\tag{86}$$\n",
"\n",
"will be calculated over the upper half of the semicircle of a unit disc. The curve $C$ is therefore the equation of a unit circle, $x^2 + y^2 = 1$, and the integration proceeds from $(1, 0) \\to (-1, 0)$, which is from the positive x-axis anticlockwise to the negative x-axis. The integral is, with the derivative in brackets,\n",
"\n",
"$$\\displaystyle \\int_C y^2 dx+2x^2y\\,dy =\\int_1^{-1} 1-x^2+2x^2\\sqrt{1-x^2}\\left(\\frac{-2x}{2\\sqrt{1-x^2}}\\right)dx=\\int_1^{-1} 1-x^2+2x^3dx $$\n",
"\n",
"## 13.6 Path independent integrals and State functions\n",
"\n",
"As an example of an integral that is _independent of the path_, consider calculating the integral $\\int_C xdx + ydy$ first along the sinusoidal path $y = \\sin(x)$ and then along the straight path $y = 2x/\\pi$ both from $(0, 0) \\to (0, \\pi/2)$. Using equation 85 the first curve produces\n",
"\n",
"$$\\displaystyle \\int x+\\sin(x)\\cos(x) dx= \\frac{1}{2}(x^2+\\sin^2(x))\\bigg|_0^{\\pi/2}= \\frac{\\pi^2}{8}+\\frac{1}{2}$$\n",
"\n",
"and the second \n",
"\n",
"$$\\displaystyle \\int_0^{\\pi/2} x+x\\frac{4}{\\pi^2}dx = \\frac{\\pi^2}{8}+\\frac{1}{2}$$\n",
"\n",
"which is the same result. Therefore, this integral is _independent_ of the path provided both paths pass through the same end points. \n",
"\n",
"There are clearly many other curves that pass through the points $(0, 0) \\to (0, \\pi/2)$ and all of these will return the same value of the integral.\n",
"\n",
"The surface $x + y$ would be called a state function if $x$ and $y$ had a meaning in thermodynamics. The value of a state function only depends on the starting and ending conditions and not on the means of getting from one to the other. The condition for the integral $f = \\int M(x, y)dx + N(x, y)dy$ to depend only on its end-points is\n",
"\n",
"$$\\displaystyle \\frac{\\partial N}{\\partial x}=\\frac{\\partial M}{\\partial y} \\qquad\\tag{87}$$\n",
"\n",
"a relationship which has been met before in the discussion on partial derivatives; see Chapter 3.12.\n",
"\n",
"![Drawing](integration-fig36.png)\n",
"\n",
"Figure 36. The integral of a _state function_ is independent of path and depends only on starting and ending positions $A$ and $B$.\n",
"_____\n",
"\n",
"## 14 Path integrals in Chemical Thermodynamics\n",
"\n",
"In thermodynamics, all the integrals you are likely to meet are line functions in 8-dimensional space - not a very appealing thought. Thermodynamics can consequently appear to be so very complicated because the choice of variables is so very large. Normally, 'natural' variables are chosen depending upon which can easily be measured, usually these are $p, V$ and $T$. However, any two independent variables can be chosen from the eight state functions $p, V, A, T, H, U, G, S$.\n",
"\n",
"The first law, which is a law of the conservation of energy, states that the heat gained by a system $q$ and the work done on the system $w$, define the change in internal energy $\\Delta U$% as\n",
"\n",
"$$\\displaystyle \\Delta U = q + w$$\n",
"\n",
"or in differential form\n",
"\n",
"$$\\displaystyle dU = \\delta q +\\delta w$$\n",
"\n",
"The $\\delta$ notation reminds us that $q$ and $w$ are not state functions but depend on the path. The integral therefore has to be performed as per normal and not obtained from the difference in starting and ending values, as is the case for a state function such as $U$. The $\\delta$ notation also means that $q$ and $w$ are not perfect differentials and are calculated by path integrals. Other authors just use $dU = dq + dw$ and leave it for you to decide which the perfect differentials are.\n",
"\n",
"Recall that heat is energy in motion which means energy is being transported from one system to another and only occurs when there is a difference in temperature. Work means a gas is expanded with a volume change of $\\Delta V$ against an external pressure $p$. Suppose the heat absorbed on expansion of a gas is taken to be a function of internal energy $U$ that changes from $U_0 \\to U_1$ and volume $V$ that changes from $V_0 \\to V_1$. Since $U$ is a state function and work is not, integrating $q =\\displaystyle \\int dq = \\int dU - \\int dw$ and replacing work with $dw = -pdV$ gives\n",
"\n",
"$$\\displaystyle q=U_1-U_0 +\\int_{V_0}^{V_1} pdV$$\n",
"\n",
"It is implied by choosing $U$ and $V$ that $p$ is a function of both, i.e. $p(U, V )$, but it is never written like that, it is assumed you know this. \n",
"\n",
"In a general thermodynamic system, it is unknown how the pressure depends on both the volume and internal energy, and how they vary along the path chosen. Therefore, the integral cannot be evaluated unless these relationships can be found. If the ideal gas law or van der Waals equation applies, then the relationship between $p$ and $V$ is known and the work integral can be calculated.\n",
"\n",
"Suppose now that $T$ and $V$ are chosen as independent variables, instead of $p$ and $V$. By definition, the heat capacity is the gradient of the heat vs temperature and if constant volume applies it is called $C_V$ where the heat is replaced by the internal energy as no work can be done, $\\displaystyle C_V=\\left( \\frac{\\partial U}{\\partial T} \\right)_V $ then $\\displaystyle \\int dU=\\int C_V dT$ and the heat change $\\displaystyle q=\\int dq=\\int dU-\\int dw$ becomes\n",
"\n",
"$$\\displaystyle q=\\int \\left(C_VdT + T\\left( \\frac{\\partial p}{\\partial T} \\right)_V dV\\right)$$\n",
"\n",
"This can be evaluated because the heat capacity and change of pressure with temperature and volume can be measured. Similarly, if $p$ and $V$ are the independent variables, then\n",
"\n",
"$$\\displaystyle q=\\int C_V\\left( \\frac{\\partial T}{\\partial p} \\right)_Vdp + C_p\\left( \\frac{\\partial T}{\\partial V} \\right)_p dV$$\n",
"\n",
"The constant pressure heat capacity is defined as $\\displaystyle C_p=\\left( \\frac{\\partial H}{\\partial T} \\right)_p $ where $H=U+pV $ is the enthalpy, internal energy plus work. If an ideal gas expansion is carried out at constant pressure, then the first term in the integration is zero; and the second term is zero if carried out at constant volume; if neither is the case then the path equation must be known and $dV/dp$ calculated to make the integral one in $p$ or $V$ alone.\n",
"\n",
"As an example of a thermodynamic calculation, consider calculating the entropy $S$, which is a state function and can be defined as\n",
"\n",
"$$\\displaystyle dS=\\frac{C_p}{T}dT-\\left( \\frac{\\partial V}{\\partial T}\\right)_pdp \\qquad\\tag{88}$$\n",
"\n",
"and in an integrated form\n",
"\n",
"$$\\displaystyle S=\\int \\frac{C_p}{T}dT-\\int\\left( \\frac{\\partial V}{\\partial T}\\right)_pdp \\qquad\\tag{89}$$\n",
"\n",
"if variables $T$ and $p$ are chosen. It has been stated that $S$ is a state function: to prove that this is true, equation 87 must hold true for the derivatives in equation 88. To illustrate this, it will be necessary to relate $T, V$, and $p$ and for which the ideal gas equation will be used. The first step is to form equation 87, which is done by looking at the 'symmetry' of the first of equations 85, $Mdx + Ndy$ and comparing it with 87, $\\displaystyle \\frac{\\partial N}{\\partial x} = \\frac{\\partial M}{\\partial y}$. In this equation $M$ is a derivative with respect to $y$, and $N$ to $x$. Therefore, choosing $M = C_p /T$ and $N = (\\partial V/\\partial T)_P$ these must be functions of the other variable used in equation 88 or 89. This means that equation 87 becomes\n",
"\n",
"$$\\displaystyle \\frac{\\partial }{\\partial p}\\left(\\frac{C_p}{T}\\right) =\\frac{\\partial}{\\partial T}\\left(\\frac{\\partial V}{\\partial T}\\right)_p \\qquad\\tag{90}$$\n",
"\n",
"Next, it is shown that this relationship is true. As the ideal gas law is $pV = RT$ then $(\\partial V/\\partial T)_p = R/p$ and so\n",
"\n",
"$$\\displaystyle \\frac{1 }{T}\\frac{\\partial C_p}{\\partial p} =\\frac{\\partial}{\\partial T}\\left(\\frac{R}{p}\\right)_p \\qquad\\tag{91}$$\n",
"\n",
"The heat capacity is by definition, $(dU/dT)_p$ making the left-hand side of equation 91\n",
"\n",
"$$\\displaystyle \\frac{1 }{T}\\frac{\\partial C_p}{\\partial p} = \\frac{1 }{T}\\frac{\\partial^2 U}{\\partial p\\partial T}=0$$\n",
"\n",
"because the internal energy $U$ of an ideal gas depends only on the temperature. The right-hand side of equation 91 is also zero because $\\displaystyle \\frac{\\partial }{\\partial T}\\left( \\frac{R}{p}\\right)=0$, verifying that $S$ is a state function.\n",
"\n",
"## 14.1 State functions do not depend on the path\n",
"\n",
"To show that $S$ does not depend on the path, the entropy, $S$, of 1 mole of an ideal gas, expanded reversibly, will be calculated using equation 89. The starting pressure and temperature are $(p_0, T_0)$ (point A, Fig. 36) and ending $(p_1, T_1)$ (point B) and the calculation follows each of the two paths shown in (a) lines $C_1 + C_2$ and (b) line $C_3$. The heat capacity is treated as a constant over the range $p_0\\to p_1$.\n",
"\n",
"Path (a) consists of two straight lines $C_1$ and $C_2$ at right angles to one another. $C_1$ is the path $P_0 \\to P_1$ at $T_0$, then $C_2$ from $T_0 \\to T_1$ at $P_1$ and path (b) is along a straight line $C_3$ from start to finish.\n",
"\n",
"The method to follow is to:\n",
"\n",
"$\\quad$**(a)** Substitute for any partial derivatives using (in this example) the ideal gas law to\n",
"make an equation in $p$ or $T$ as necessary.\n",
"\n",
"$\\quad$**(b)** Use equation 85 to make equations in $dp$ and$ dT$.\n",
"\n",
"$\\quad$**(c)** Work out the remaining derivative $dp/dT$ or $dT/dp$ depending on the path taken.\n",
"\n",
"$\\quad$**(d)** Integrate the resulting equation.\n",
"\n",
"In step (a), starting with equation 89, substituting the partial derivative using the ideal gas law produces\n",
"\n",
"$$\\displaystyle S=\\int \\frac{C_p}{T}dT-\\int\\frac{R}{p}dp \\qquad\\tag{92}$$\n",
"\n",
"Step (b): making the integral a function of $p$ and of $T$ alone gives\n",
"\n",
"$$\\displaystyle S_T=\\int_{p_0}^{p_1} \\left(\\frac{C_p}{T}\\frac{dT}{dp}-\\frac{R}{p}\\right) dp, \\qquad S_p=\\int_{T_1}^{T_2} \\left(\\frac{C_p}{T}-\\frac{R}{p}\\frac{dp}{dT}\\right) dT $$\n",
"\n",
"as illustrated in equation 85.\n",
"\n",
"Steps (c) and (d): The first part of the path (A) is at constant $T=T_0$, and from $p_0 \\to p_1$, therefore as $dT/dp=0$ \n",
"\n",
"$$\\displaystyle S_p=\\int_{p_0}^p{_1}\\frac{R}{p}dp = -R\\ln\\left( \\frac{p_1}{p_0} \\right) $$\n",
"\n",
"This is also obvious because $T$ is constant along this part of path (a) and equation 92 could have been used directly. In the second step at constant $p_1$ with the temperature changing from $T_0 \\to T_1$,\n",
"\n",
"$$\\displaystyle S_p=\\int_{T_0}^{T_1} \\frac{C_p}{T}dT =C_p\\ln\\left( \\frac{T_1}{T_0} \\right) $$\n",
"\n",
"and the total change in entropy is the sum of these last two integrals.\n",
"\n",
"The same method is used for path (b) along the line $C_3$. As this path goes directly from start to finish it is\n",
"the equation of a straight line; \n",
"\n",
"$$\\displaystyle T= \\frac{T_1-T_0}{p_1-p_0}(p-p_0)+T_0,\\quad \\text{with gradient}\\quad \\displaystyle \\frac{dT}{dp}=\\frac{T_1-T_0}{p_1-p_0}=m$$\n",
"\n",
"and substituting this and $T$ into the equation for $S_T$ and integrating gives\n",
"\n",
"$$\\displaystyle S=\\int_{p_0}^{p_1} C_p\\left( \\frac{m}{m(p-p_0)+T_0}-\\frac{R}{p} \\right)dp= C_p\\ln\\left( \\frac{T_1}{T_0}\\right) -R\\ln\\left( \\frac{p_1}{p_0}\\right)$$\n",
"\n",
"which is the same as along the path (a); therefore entropy is a state function. (The first part of the last integration is a standard one: $\\int dx/(ax + b) = \\ln(ax + b)/a$).\n",
"\n",
"## 14.2 Green’s function\n",
"\n",
"A line integral of two functions is by Green's theorem equal to the surface integral around a _closed area_, or\n",
"\n",
"$$\\displaystyle \\int_CMdx+Ndy = \\int\\int \\left( \\frac{N}{dx}-\\frac{M}{dy} \\right)dxdy \\qquad\\tag{93}$$\n",
"\n",
"where integration is taken in an anticlockwise direction. It can be evaluated either as two or more line integrals, one for each part of the loop, or from the double integral depending which is easier, but is always around a closed area. The notation for this is often given as $\\int_C Mdx + Ndy$ . If the curve is given para metrically, the integral is $\\displaystyle A= \\frac{1}{2}\\int \\left( x\\frac{N}{dt}-y\\frac{M}{dt} \\right)dt$.\n",
"\n",
"Consider equation 86, which was evaluated around the semicircle of a unit circle from $A$ to $B$. The result was $\\displaystyle \\int_Cy^2dx+2x^2ydy=-\\frac{4}{3}$.\n",
"\n",
"The second part of the calculation of the closed loop must also contain the line integral from $B$ to $A$, the curve for this is $y = 0$ and therefore the integral $B \\to A$ is zero because $y$ is zero, in both limits of the integral. The total line integral from $A \\to B$ then straight to $A$ again is therefore also $-4/3$.\n",
"\n",
"Now consider the Green's function integral, equation 93 with $M \\equiv y^2$ and $N \\equiv 2x^2y$ then\n",
"\n",
"$$\\displaystyle \\begin{align}\n",
"\\displaystyle \\int_Cy^2dx+2x^2ydy &=\\int\\int \\left( \\frac{N}{dx}-\\frac{M}{dy} \\right)dxdy \\\\\n",
"&=\\int_{-1}^1 \\int_0^{\\sqrt{1-x^2}} (4xy-2y)dydx =\\int_{-1}^1 (2x-1)(1-x^2)dx=-\\frac{4}{3} \\end{align} $$\n",
"\n",
"and note the change of order of integration in the second line which ensures that an integral in $x$ with constants as limits is the final integration. The result is the same that obtained before.\n",
"\n",
"![Drawing](integration-fig37.png) \n",
"\n",
"Figure 37. Integrating around the curve $A \\to B \\to A$.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}