1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
|
% \iffalse meta-comment
% File: thermodynamics.dtx Copyright (C) 2022-2023 Karl D. Hammond
%
% Karl D. Hammond
% Chemical Engineering Program
% University of Missouri
% Contact: hammondkd@missouri.edu
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is K. D. Hammond.
%
% This work consists of the files thermodynamics.dtx and thermodynamics.ins
% and the derived files thermodynamics.sty, thermodynamics.pdf,
% thermodynamics-examples.tex, and thermodynamics-examples.pdf.
% \fi
%
% \iffalse
%^^A FIXME: need correct date of release once you update this
%^^X\GetIdInfo $Id: thermodynamics.dtx 2.00 2023/11/16 Karl D. Hammond <hammondkd@missouri.edu> $
%^^X {thermodynamics notation}
%<*driver>
%^^X\ProvidesFile{\ExplFileName}
\ProvidesFile{thermodynamics.dtx}
%</driver>
%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\RequirePackage{expl3}
%<package>\ProvidesPackage{thermodynamics}
%<*package>
[2023/11/16 v2.00 thermodynamics notation]
%</package>
%^^X {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
%<*driver>
\documentclass[11pt,letterpaper]{ltxdoc}
%^^X\bool_set_false:N \l__codedoc_allow_indexing_bool
\usepackage[margin=0.80in,left=2.05in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{pxfonts}
\usepackage{array}
\usepackage{booktabs}
\usepackage{footmisc}
\usepackage[labelfont=bf,labelsep=period,font=small]{caption}
\GetFileInfo{thermodynamics.dtx}
\usepackage{thermodynamics}[\filedate\space\fileversion]
\DisableCrossrefs
\CodelineIndex
\PageIndex
\CodelineNumbered
\RecordChanges
%^^X Preparing to use l3doc.cls, but it's not quite mature yet....
%^^A\DisableDocumentation
%^^A\DisableImplementation
%^^X\ExplSyntaxOff
\let\tn\cs
\let\env\texttt
\let\pkg\textsf
\begin{document}
\DocInput{thermodynamics.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{2387}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \changes{v1.00}{2022/04/29}{Initial public release}
% \changes{v2.00}{2023/11/16}{Revision to use \LaTeX3
% (\pkg{expl3}/\pkg{xparse}) syntax layer}
%
% \newcommand*{\setmarginparsize}[1]
% {\bgroup
% \RenewExpandableDocumentCommand{\MacroFont}{}{\fontencoding\encodingdefault
% \fontfamily\ttdefault
% \fontseries\mddefault
% \fontshape\shapedefault
% #1}
% }
% \newcommand*{\restoremarginparsize}{\egroup}
%
% \GetFileInfo{thermodynamics.dtx}
%^^X \title{The \textsf{thermodynamics} package\thanks{This document
%^^X corresponds to \textsf{thermodynamics}~\ExplFileVersion,
%^^X dated \ExplFileDate.}}
% \title{The \textsf{thermodynamics} package\thanks{This document
% corresponds to \textsf{thermodynamics}~\fileversion,
% dated \filedate.}}
% \author{Karl D. Hammond \\ \texttt{hammondkd@missouri.edu}}
%^^X \date{\ExplFileDate}
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
% A package, \textsf{thermodynamics}, is defined that makes typesetting
% quantities found in thermodynamics texts relatively simple. The commands are
% flexible and intended to be relatively intuitive. It handles several sets
% of notation for total, specific, and molar quantities; allows changes between
% symbols (e.g., $A$ vs.\ $F$ for Helmholtz free energy); and greatly
% simplifies the typesetting of symbols and partial derivatives commonly
% encountered in mixture thermodynamics. Changes of one's notes from one
% textbook to another can be achieved relatively easily by changing package
% options.
% \end{abstract}
%
%^^X \begin{documentation}
% \section{Introduction}
% The purpose of this package is to simplify the typesetting of equations in
% thermodynamics, particularly chemical engineering thermodynamics, which are
% often cumbersome to enter. For example, consider the following equation:
% \begin{equation}
% d\Ut = \Partial*{\Ut}{\St}{\Vt,\allNs} \,d\St
% + \Partial*{\Ut}{\Vt}{\St,\allNs} \,d\Vt
% + \sumall_i \Partial*{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}} d\Nt_i.
% \label{eq:chain-rule-U}
% \end{equation}
% This equation is pretty basic, and equations like it occur all the time in
% thermodynamics. Without this package, you might typeset it like this:
% \begin{verbatim}
% \[ d\underline{U} =
% \left(\frac{\partial\underline{U}}
% {\partial\underline{S}}\right)_{\underline{V},\vec{n}}
% d\underline{S}
% + \left(\frac{\partial\underline{U}}
% {\partial\underline{V}}\right)_{\underline{S},\vec{n}}
% d\underline{V}
% + \sum_{i=1}^C \left(\frac{\partial\underline{U}}
% {\partial n_i}\right)_{\underline{S},\underline{V},n_{j\neq i}}
% dn_i. \]
%\end{verbatim}
% This is a lot of code, and even then the output is slightly clunky:
% \[ d\underline{U} =
% \left(\frac{\partial\underline{U}}
% {\partial\underline{S}}\right)_{\underline{V},\vec{n}}
% d\underline{S}
% + \left(\frac{\partial\underline{U}}
% {\partial\underline{V}}\right)_{\underline{S},\vec{n}}
% d\underline{V}
% + \sum_{i=1}^C \left(\frac{\partial\underline{U}}
% {\partial n_i}\right)_{\underline{S},\underline{V},n_{j\neq i}}
% dn_i.
% \]
% It is also frustratingly difficult to change one's notes or handouts from one
% textbook that uses, say, $n_1$ to denote moles of component 1 to another
% textbook that uses $N_1$ for the same quantity, or perhaps denotes the
% total internal energy as $U$ or $U^t$ rather than $\Ut$.
% For example, if you wanted it to be
% \[\begin{thermomolesrange}
% \begin{thermoextensiveplain}
% \RenewExpandableDocumentCommand{\Nt}{}{N}
% \RenewExpandableDocumentCommand{\ncomponents}{}{\mathcal{C}}
% d\Ut = \Partial*{\Ut}{\St}{\Vt,\allNs} \,d\St
% + \Partial*{\Ut}{\Vt}{\St,\allNs} \,d\Vt
% + \sumall_i \Partial*{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}} d\Nt_i.
% \end{thermoextensiveplain}
% \end{thermomolesrange}
% \]
% without changing any of your code---to update it across all handouts, exams,
% and homework sets after changing textbooks, say---you would be out of luck
% (or in for a lot of work).
%
% With this package, you could reduce the code to typeset this equation to
% \begin{verbatim}
% \begin{equation}
% d\Ut = \Partial*{\Ut}{\St}{\Vt,\allNs} d\St
% + \Partial*{\Ut}{\Vt}{\St,\allNs} d\Vt
% + \sumall_i \Partial*{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}} d\Nt_i
% \end{equation}
%\end{verbatim}
% and it will render similarly to Equation~\eqref{eq:chain-rule-U}, including
% the shortened underscores and negative kerning.
% If you later decide to change the notation such that extensive properties are
% not underlined, you can do that without changing any of your code (just
% change a package option). Similarly, if you want $\vec{n}$ replaced by
% $n_1,\dots,n_C$, you can do that with a package option, too.
%
% The package handles second derivatives, too. For example,
% \begin{verbatim}
% \[ \Partial*{\Hm}{T}{P} = T\Partial*{\Sm}{T}{P}
% = -T\PartialSecond*{\Gm}{T}{P} = \cP \]
%\end{verbatim}
% renders (using the default options)
% \[ \Partial*{\Hm}{T}{P} = T\Partial*{\Sm}{T}{P}
% = -T\PartialSecond*{\Gm}{T}{P} = \cP. \]
% Similarly, macros are defined for mixed second partial derivatives that allow
% things like
% \begin{verbatim}
% \[ \Partial*{\Gpm_i}{P}{T,\allNs}
% = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}} = \Vpm_i \],
%\end{verbatim}
% which renders
% \[ \Partial*{\Gpm_i}{P}{T,\allNs}
% = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}} = \Vpm_i
% \]
% using the defaults.
%
%^^A-------------------------------------------------------------------------
%
% \section{Using the Package} \label{sec:using}
% There are three categories of macros defined in this package: macros
% that produce symbols (or groups of them), macros that typeset derivatives,
% and macros that are used internally that the user need not know about.
% There are also several environments that allow the user to change notation
% temporarily.
%
% \subsection{Predefined Symbols}
% The macros used to produce symbols fall into five categories: extensive
% properties, molar properties, specific properties (i.e., per unit mass),
% partial molar properties, and shortcut macros (e.g., macros for the heat
% capacities, saturation pressure, and so forth). The macros corresponding to
% extensive, molar, and specific properties are shown in
% Table~\ref{table:symbols}. Examples using the enthalpy are
% \DescribeMacro{\Ht}
% \DescribeMacro{\Hm}
% \DescribeMacro{\Hs}
% \DescribeMacro{\Hpm}
% \begin{verbatim}
% \[ \Ht \quad \Hm \quad \Hs \quad \Hpm_i. \]
%\end{verbatim}
% Using the default package options, the above renders as
% \[ \Ht \quad \Hm \quad \hat H \quad \Hpm{i}. \]
% In addition, the properties in
% Table~\ref{table:conveniences} are defined for convenience.
%
% \DescribeMacro{\Ut}
% \DescribeMacro{\Um}
% How these symbols are rendered can be customized by package options. As long
% as the user consistently uses \cs{Ut} to render the total internal energy,
% \cs{Um} to render the molar internal energy, and so forth, switching notation
% from, say, $\Ut$ to $U^t$ for extensive properties is trivial.
%
% \DescribeMacro{\cP}
% \DescribeMacro{\cV}
% \DescribeMacro{\cPt}
% \DescribeMacro{\cVt}
% \DescribeMacro{\cPs}
% \DescribeMacro{\cVs}
% \DescribeMacro{\cPpm}
% \DescribeMacro{\cVpm}
% The heat capacities (see Table~\ref{table:conveniences}) are generally
% assumed to be molar (e.g., \cs{cP} is interpreted to be the molar heat
% capacity). To get the specific heat capacities, the macros \cs{cPs} and
% \cs{cVs} are provided, which by default render as $\cPs$ and $\cVs$,
% respectively. There are also extensive versions, so \cs{cPt} and \cs{cVt}
% will render as $\cPt$ and $\cVt,$
% respectively. Note that \cs{cP} and friends require you to surround
% \cs{text} with brackets. For example, \verb"\cP_i^\text{A}" will not work,
% nor will \verb"\cP^\text{A}_i"; you need to use \verb"\cP_i^{\text{A}}" and
% \verb"\cP^{\text{A}}_i". Using \verb"\cP^\IG_i" will work as expected.
%
% You can also get partial molar heat capacities via \cs{cPpm} and \cs{cVpm},
% though the latter's mathematical definition is a bit hard to wrap one's head
% around:
% \begin{verbatim}
% \[ \cVpm_i = \Partial*{\cVt}{\Nt_i}{T,P,\allNsbut{i}}
% = \frac{\partial}{\partial\Nt_i}
% \left[ -T\PartialSecond{\Ft}{T}{\Vt,\allNs}
% \right]_{T,P,\allNsbut{i}} \]
%\end{verbatim}
% yields
% \[ \cVpm{i} = \Partial*{\cVt}{\Nt_i}{T,P,\allNsbut{i}}
% = \frac{\partial}{\partial\Nt_i}
% \left[ -T\PartialSecond{\Ft}{T}{\Vt,\allNs}
% \right]_{T,P,\allNsbut{i}}. \]
%
% \begin{table}
% \caption{Commands defined in this package to represent extensive
% thermodynamic quantities and their molar and specific analogs.
% These macros should be used even if the symbol the user
% wishes to use does not match the command used (e.g., \cs{Ft}
% for total Helmholtz free energy even if it ends up being set as
% $\Ft$)\@.
% }
% \label{table:symbols}
%^^A TODO The \leavevmode macro here is to prevent whitespace from building
%^^A up due to a bug in old versions of hypdoc. It should be harmless to
%^^A leave it in there, but consider removing it at some point.
% \leavevmode
% \SpecialMacroIndex{\Qt}\relax
% \SpecialMacroIndex{\Qm}\relax
% \SpecialMacroIndex{\Qs}\relax
% \SpecialMacroIndex{\Wt}\relax
% \SpecialMacroIndex{\Wm}\relax
% \SpecialMacroIndex{\Ws}\relax
% \SpecialMacroIndex{\Et}\relax
% \SpecialMacroIndex{\Em}\relax
% \SpecialMacroIndex{\Es}\relax
% \SpecialMacroIndex{\Epm}\relax
% \SpecialMacroIndex{\EEt}\relax
% \SpecialMacroIndex{\EE}\relax
% \SpecialMacroIndex{\EEs}\relax
% \SpecialMacroIndex{\EEpm}\relax
% \SpecialMacroIndex{\ERt}\relax
% \SpecialMacroIndex{\ER}\relax
% \SpecialMacroIndex{\ERs}\relax
% \SpecialMacroIndex{\ERpm}\relax
% \SpecialMacroIndex{\Ut}\relax
% \SpecialMacroIndex{\Um}\relax
% \SpecialMacroIndex{\Us}\relax
% \SpecialMacroIndex{\Upm}\relax
% \SpecialMacroIndex{\UEt}\relax
% \SpecialMacroIndex{\UE}\relax
% \SpecialMacroIndex{\UEs}\relax
% \SpecialMacroIndex{\UEpm}\relax
% \SpecialMacroIndex{\URt}\relax
% \SpecialMacroIndex{\UR}\relax
% \SpecialMacroIndex{\URs}\relax
% \SpecialMacroIndex{\URpm}\relax
% \SpecialMacroIndex{\Ht}\relax
% \SpecialMacroIndex{\Hm}\relax
% \SpecialMacroIndex{\Hs}\relax
% \SpecialMacroIndex{\Hpm}\relax
% \SpecialMacroIndex{\HEt}\relax
% \SpecialMacroIndex{\HE}\relax
% \SpecialMacroIndex{\HEs}\relax
% \SpecialMacroIndex{\HEpm}\relax
% \SpecialMacroIndex{\HRt}\relax
% \SpecialMacroIndex{\HR}\relax
% \SpecialMacroIndex{\HRs}\relax
% \SpecialMacroIndex{\HRpm}\relax
% \SpecialMacroIndex{\St}\relax
% \SpecialMacroIndex{\Sm}\relax
% \SpecialMacroIndex{\Ss}\relax
% \SpecialMacroIndex{\Spm}\relax
% \SpecialMacroIndex{\SEt}\relax
% \SpecialMacroIndex{\SE}\relax
% \SpecialMacroIndex{\SEs}\relax
% \SpecialMacroIndex{\SEpm}\relax
% \SpecialMacroIndex{\SRt}\relax
% \SpecialMacroIndex{\SR}\relax
% \SpecialMacroIndex{\SRs}\relax
% \SpecialMacroIndex{\SRpm}\relax
% \SpecialMacroIndex{\Ft}\relax
% \SpecialMacroIndex{\Fm}\relax
% \SpecialMacroIndex{\Fs}\relax
% \SpecialMacroIndex{\Fpm}\relax
% \SpecialMacroIndex{\FEt}\relax
% \SpecialMacroIndex{\FE}\relax
% \SpecialMacroIndex{\FEs}\relax
% \SpecialMacroIndex{\FEpm}\relax
% \SpecialMacroIndex{\FRt}\relax
% \SpecialMacroIndex{\FR}\relax
% \SpecialMacroIndex{\FRs}\relax
% \SpecialMacroIndex{\FRpm}\relax
% \SpecialMacroIndex{\Gt}\relax
% \SpecialMacroIndex{\Gm}\relax
% \SpecialMacroIndex{\Gs}\relax
% \SpecialMacroIndex{\Gpm}\relax
% \SpecialMacroIndex{\GEt}\relax
% \SpecialMacroIndex{\GE}\relax
% \SpecialMacroIndex{\GEs}\relax
% \SpecialMacroIndex{\GEpm}\relax
% \SpecialMacroIndex{\GRt}\relax
% \SpecialMacroIndex{\GR}\relax
% \SpecialMacroIndex{\GRs}\relax
% \SpecialMacroIndex{\GRpm}\relax
% \SpecialMacroIndex{\At}\relax
% \SpecialMacroIndex{\Am}\relax
% \SpecialMacroIndex{\As}\relax
% \SpecialMacroIndex{\Apm}\relax
% \SpecialMacroIndex{\Nt}\relax
% \SpecialMacroIndex{\Lt}\relax
% \SpecialMacroIndex{\Lm}\relax
% \SpecialMacroIndex{\Ls}\relax
% \SpecialMacroIndex{\Lpm}\relax
% \SpecialMacroIndex{\LEt}\relax
% \SpecialMacroIndex{\LE}\relax
% \SpecialMacroIndex{\LEs}\relax
% \SpecialMacroIndex{\LEpm}\relax
% \SpecialMacroIndex{\LRt}\relax
% \SpecialMacroIndex{\LR}\relax
% \SpecialMacroIndex{\LRs}\relax
% \SpecialMacroIndex{\LRpm}\relax
% \centering
% \begin{minipage}{\linewidth}\renewcommand*{\footnoterule}{\vskip-1.75ex}%
% \centering\scriptsize\setlength{\tabcolsep}{0.05in}
% \begin{tabular}{l l l l l l l l l l l l l}
% \toprule
% & & & & & \multicolumn{4}{c}{Excess}
% & \multicolumn{4}{c}{Residual (Departure)} \\
% \cmidrule(r{0.5ex}){6-9}
% \cmidrule(l{0.5ex}){10-13}
% Property & Total & Molar & Specific & \parbox[b]{0.45in}{Partial Molar}
% & T & M & S & PM & T & M & S & PM \\
% \midrule
% Heat & \cs{Qt} & \cs{Qm} & \cs{Qs} & \\
% Work & \cs{Wt} & \cs{Wm} & \cs{Ws} & \\
% Total energy & \cs{Et} & \cs{Em} & \cs{Es} & \cs{Epm}
% & \cs{EEt} & \cs{EE} & \cs{EEs} & \cs{EEpm}
% & \cs{ERt} & \cs{ER} & \cs{ERs} & \cs{ERpm} \\
% Internal energy & \cs{Ut} & \cs{Um} & \cs{Us} & \cs{Upm}
% & \cs{UEt} & \cs{UE} & \cs{UEs} & \cs{UEpm}
% & \cs{URt} & \cs{UR} & \cs{URs} & \cs{URpm} \\
% Enthalpy & \cs{Ht} & \cs{Hm} & \cs{Hs} & \cs{Hpm}
% & \cs{HEt} & \cs{HE} & \cs{HEs} & \cs{HEpm}
% & \cs{HRt} & \cs{HR} & \cs{HRs} & \cs{HRpm} \\
% Entropy & \cs{St} & \cs{Sm} & \cs{Ss} & \cs{Spm}
% & \cs{SEt} & \cs{SE} & \cs{SEs} & \cs{SEpm}
% & \cs{SRt} & \cs{SR} & \cs{SRs} & \cs{SRpm} \\
% Volume & \cs{Vt} & \cs{Vm} & \cs{Vs} & \cs{Vpm}
% & \cs{VEt} & \cs{VE} & \cs{VEs} & \cs{VEpm}
% & \cs{VRt} & \cs{VR} & \cs{VRs} & \cs{VRpm} \\
% Helmholtz free energy & \cs{Ft} & \cs{Fm} & \cs{Fs} & \cs{Fpm}
% & \cs{FEt} & \cs{FE} & \cs{FEs} & \cs{FEpm}
% & \cs{FRt} & \cs{FR} & \cs{FRs} & \cs{FRpm} \\
% Gibbs free energy & \cs{Gt} & \cs{Gm} & \cs{Gs} & \cs{Gpm}
% & \cs{GEt} & \cs{GE} & \cs{GEs} & \cs{GEpm}
% & \cs{GRt} & \cs{GR} & \cs{GRs} & \cs{GRpm} \\
% Surface area & \cs{At} & \cs{Am} & \cs{As} & \cs{Apm} \\
% Grand potential\footnote{The grand potential,
% $\begin{thermomolesrange}\Lt(T,\Vt,\allmus)\end{thermomolesrange}
% = \Ut - T\St - \sumall_i \mu_i \Nt_i,$
% is also called the Landau free energy by some authors.}
% & \cs{Lt} & \cs{Lm} & \cs{Ls} & \cs{Lpm}
% & \cs{LEt} & \cs{LE} & \cs{LEs} & \cs{LEpm}
% & \cs{LRt} & \cs{LR} & \cs{LRs} & \cs{LRpm} \\
% Moles & \cs{Nt} & \\
% \bottomrule
% \end{tabular}
% \end{minipage}
% \end{table}
%
% \begin{table}
% \caption{Convenience macros and their default symbols.
% These are generally ``smart'': for example,
% \texttt{\textbackslash cP\_i} renders as $C_{P,i}$, as expected, and
% \texttt{\textbackslash cP\_i\^{}\textbackslash std} renders as
% $C_{P,i}^\circ$, also as expected. You can also reverse it:
% \texttt{\textbackslash cP\^{}\textbackslash std\_i} becomes
% $C^\circ_{P,i}$.}
% \label{table:conveniences}
%^^A TODO The \leavevmode macro here is to prevent whitespace from building
%^^A up due to a bug in old versions of hypdoc. It should be harmless to
%^^A leave it in there, but consider removing it at some point.
% \leavevmode
% \SpecialMacroIndex{\cP}\relax
% \SpecialMacroIndex{\cV}\relax
% \SpecialMacroIndex{\kappaT}\relax
% \SpecialMacroIndex{\kappaS}\relax
% \SpecialMacroIndex{\alphaP}\relax
% \SpecialMacroIndex{\alphaS}\relax
% \SpecialMacroIndex{\muJT}\relax
% \SpecialMacroIndex{\heatcapacitysymbol}\relax
% \SpecialMacroIndex{\compressibilitysymbol}\relax
% \SpecialMacroIndex{\expansivitysymbol}\relax
% \SpecialMacroIndex{\amix}\relax
% \SpecialMacroIndex{\fpure}\relax
% \SpecialMacroIndex{\fmix}\relax
% \SpecialMacroIndex{\fsat}\relax
% \SpecialMacroIndex{\phipure}\relax
% \SpecialMacroIndex{\phimix}\relax
% \SpecialMacroIndex{\phisat}\relax
% \SpecialMacroIndex{\Psat}\relax
% \SpecialMacroIndex{\Pvap}\relax
% \SpecialMacroIndex{\sat}\relax
% \SpecialMacroIndex{\Henryrat}\relax
% \SpecialMacroIndex{\Henrymol}\relax
% \SpecialMacroIndex{\gammarat}\relax
% \SpecialMacroIndex{\gammamol}\relax
% \SpecialMacroIndex{\Deltamix}\relax
% \SpecialMacroIndex{\Deltarxn}\relax
% \SpecialMacroIndex{\Deltavap}\relax
% \SpecialMacroIndex{\Deltasub}\relax
% \SpecialMacroIndex{\Deltafus}\relax
% \SpecialMacroIndex{\mixing}\relax
% \SpecialMacroIndex{\reaction}\relax
% \SpecialMacroIndex{\fusion}\relax
% \SpecialMacroIndex{\vaporization}\relax
% \SpecialMacroIndex{\sublimation}\relax
% \begin{minipage}{\linewidth}
% \small
% \addtolength{\tabcolsep}{-2.75pt}\relax
% \addtolength{\extrarowheight}{0.75ex}\relax
% \renewcommand*{\footnoterule}{\vskip-1.5ex}\relax
% \begin{tabular}{l l l l l}
% \toprule
% \\[-1.5\normalbaselineskip]
% Name & Macro & Sym. & Definition & Base Symbol Macro \\
% \midrule
% Isobaric heat capacity & \cmd\cP\footnote{\relax
% Extensive and specific (per-unit-mass) versions are available
% as \cs{cPt} and \cmd\cPs, respectively, with similar macros for the
% isochoric heat capacity.\label{fn:cP}}
% & \(cP\) & \(\displaystyle T\Partial{\Sm}{T}{P}\)
% & \cmd\heatcapacitysymbol \\[2.0ex]
% Isochoric heat capacity & \verb"\cV"\footref{fn:cP} & \(\cV\)
% & \(\displaystyle T\Partial{\Sm}{T}{\Vm}\)
% & \cmd\heatcapacitysymbol \\[2.0ex]
% Isothermal compressibility & \cmd\kappaT & $\kappaT$
% & \(\displaystyle -\frac{1}{\Vm} \Partial{\Vm}{P}{T} \)
% & \cmd\compressibilitysymbol \\[2.0ex]
% Isentropic compressibility & \cmd\kappaS & $\kappaS$
% & \(\displaystyle -\frac{1}{\Vm} \Partial{\Vm}{P}{\Sm}\)
% & \cmd\compressibilitysymbol \\[2.0ex]
% Isobaric expansivity & \cmd\alphaP & $\alphaP$
% & \(\displaystyle \frac{1}{\Vm} \Partial{\Vm}{T}{P}\)
% & \cmd\expansivitysymbol \\[2.0ex]
% Isentropic expansivity & \cmd\alphaS & $\alphaS$
% & \(\displaystyle \frac{1}{\Vm} \Partial{\Vm}{T}{\Sm}\)
% & \cmd\expansivitysymbol \\[2.0ex]
% Joule--Thomson coeff. & \cmd\muJT & $\muJT$
% & \(\displaystyle \Partial{T}{P}{\Hm}\) & \cmd\JTsymbol \\
% Pure fugacity & \cmd\fpure & $f$ & $\phi P$ \\
% Mixture fugacity & \cmd\fmix & $\fmix$
% & $\fmix_i = x_i\phimix_i P$ \\[0.5ex]
% Saturation fugacity & \cmd\fsat & $\fsat$
% & $\phisat \Psat$ & \cmd\sat \\
% Pure fugacity coefficient & \cmd\phipure & $\phipure$ &
% \multicolumn{2}{l}{\( \phipure_i
% = \exp\left(\frac{1}{RT}\int_0^P \Vm_i(T,p)
% - \frac{RT}{p}\,dp\right) \)} \\
% Mixture fugacity coeff.\ & \cmd\phimix & $\phimix$
% & \multicolumn{2}{l}{\( \phimix_i
% = \exp\left(\frac{1}{RT}\int_0^P \Vpm{i}(T,p,\allXs)
% - \frac{RT}{p}\,dp\right) \)} \\
% Henry's constant (rational) & \cmd\Henryrat & $\Henryrat$
% & $\gamma_i^\infty f_i$ \\
% Henry's constant (molal) & \cmd\Henrymol & $\Henrymol$
% & $M_s \gamma_i^\infty f_i$ \\
% Rational activity coeff.\ & \cmd\gammarat & $\gammarat$
% & $\gamma/\gamma^\infty$ \\
% Molal activity coeff.\ & \cmd\gammamol & $\gammamol$
% & $x_s \gamma/\gamma^\infty$ \\
% Saturation fugacity coeff.\ & \cmd\phisat & $\phisat$
% & $\phipure(T,\Psat)$ & \cmd\sat \\
% Saturation pressure & \cmd\Psat & $\Psat$ && \cmd\sat \\
% Vapor pressure & \cmd\Pvap & \multicolumn{3}{l}{Currently a synonym
% for \cs{Psat}\footnote{If you want \cs{Pvap} to produce $P^\text{vap}$
% instead of $\Psat$, you should redefine the \cs{sat} macro.}} \\
% Standard state & \cmd\std\footnote{Typical usage would be
% \texttt{\$\cs{mu}\_i = \cs{mu}\textasciicircum\cs{std}\_i
% + RT \cs{log} a\_i\$},
% yielding $\mu_i = \mu_i^\std + RT \log a_i$.} & $\std$ \\
% Standard pressure & \cmd\Pstd & $\Pstd$ & & \cs{std} \\
% Standard fugacity & \cmd\fstd & $\fstd$ & $\fpure(T,\Pstd)$ & \cs{std}
% \\
% Change on mixing & \cmd\Deltamix\footnote{The usual usage would be
% something like
% \texttt{\$\cs{Deltamix}\cs{Vm}\textasciicircum\cs{IGM} = 0\$}.\relax
% \label{fn:Deltausage}}
% & $\Delta M$\textsubscript{mix}
% & $M - \sumall_i x_i M_i$ & \cmd\mixing \\
% Change on reaction & \cmd\Deltarxn\footref{fn:Deltausage}
% & $\Deltarxn M$
% & $\sumall_i \nu_i M_i$ & \cmd\reaction \\
% Change on melting & \cmd\Deltafus\footref{fn:Deltausage}
% & $\Deltafus M$ & $M^L - M^S$ & \cmd\fusion \\
% Change on boiling & \cmd\Deltavap\footref{fn:Deltausage}
% & $\Deltavap M$ & $M^V - M^L$ & \cmd\vaporization \\
% Change on subliming & \cmd\Deltasub\footref{fn:Deltausage}
% & $\Deltasub M$ & $M^V - M^S$ & \cmd\sublimation \\
% \bottomrule
% \end{tabular}
% \end{minipage}
% \end{table}
%
% \subsection{Partial Molar Properties}
% \DescribeMacro{\Upm}
% \DescribeMacro{\Vpm}
% Partial molar quantities are defined with the suffix \verb"pm".
% For example, \cs{Upm} refers to the partial molar internal energy. There
% are two options for how to enter partial molar quantities: as commands or
% as super/subscripts. For example,
% \begin{verbatim}
% \[ \Upm{i} \quad \Upm[\IG]{i} \quad \Vpm_i \quad \Vpm^\IG_i \]
%\end{verbatim}
% will typeset as
% \[ \Upm{i} \quad \Upm[\text{IG}]{i} \quad \Vpm{i} \quad \Vpm^{\text{IG}}_i.\]
% There are also partial molar heat capacities available via the macros
% \cs{cPpm} and \cs{cVpm}.
% \textbf{Important}: The \tn{text} command defined by the \pkg{amstext}
% package is usually robust enough that something like \verb"\Um^\text{L}" will
% work as expected, without additional braces. This does \emph{not} work for
% partial molar properties; for example, \verb"\Hpm^\text{L}_i" will produce an
% error, as will \verb"\Hpm_i^\text{L}". The expression
% \verb"\Hpm_i^{\text{L}}" will work as expected.
%
% \DescribeMacro{\partialmolar}
% New partial molar properties can be defined for any ``simple'' symbol using
% the \cs{partialmolar} macro. ``Simple'' means it has no subscripts or
% superscripts. For example, the macro for the partial molar Gibbs free energy
% is effectively defined via the macro
% \DescribeMacro{\Gpm}
% \begin{verbatim}
% \NewDocumentCommand{\Gpm}{}{\partialmolar{G}}.
%\end{verbatim}
% A list of pre-defined macros for total, molar, specific, and partial molar
% quantities commonly used in thermodynamics is included in
% Table~\ref{table:symbols}.
%
% \subsection{Defining New Properties}
% \DescribeMacro{\NewExtensiveProperty}
% Users can create new properties using a family of commands. Typically, a
% user would want to define at least the total, molar, and specific properties,
% which can be accomplished by the \cs{NewExtensiveProperty} command.
% For example,
% \begin{verbatim}
% \NewExtensiveProperty{J}{K}
%\end{verbatim}
% \NewExtensiveProperty{J}{K}\relax
% would define the commands \cs{Jt}, \cs{Jm}, and \cs{Js}, which would produce
% (using the default package options) the symbols $\Jt$, $K$, and $\hat{K}$,
% respectively.
%
% \DescribeMacro{\NewPartialMolarProperty}%
% Partial molar properties can be created either with the \cs{partialmolar}
% macro directly as described above or with \cs{NewPartialMolarProperty}, which
% has the same argument style as \cs{NewExtensiveProperty}.
%
% \DescribeMacro{\NewExcessProperty}%
% \DescribeMacro{\NewResidualProperty}%
% Similarly, one can define commands for the total, molar, and specific excess
% properties using \cs{NewExcessProperty} in a similar manner, and similar
% commands for the residual properties with \cs{NewResidualProperty}.
%
% \setmarginparsize{\footnotesize}
% \DescribeMacro{\NewThermodynamicProperty}\relax
% \restoremarginparsize
% \NewThermodynamicProperty{B}{B}\relax
% \NewExtensiveProperty{M}{M}\relax
% It is common that a user wants the total, molar, specific, and partial molar
% commands for a new symbol, as well as excess and residual (departure)
% properties for each case. Users can define such properties---common examples
% are $\Bt$ and $\Mt$ to represent uncommon or arbitrary properties---by using
% \cs{NewThermodynamicProperty}, which calls all four of the aforementioned
% declarations on the same command/\allowbreak{}symbol combinations. For
% example,
% \begin{verbatim}
% \NewThermodynamicProperty{B}{B}
%\end{verbatim}
% defines the commands \cs{Bt}, \cs{Bm}, \cs{Bs}, and \cs{Bpm}, which define
% the total, molar, specific, and partial molar properties, respectively.
% It also defines \cs{BEt}, \cs{BE}, \cs{BEs}, and \cs{BEpm} for the
% corresponding excess properties, and \cs{BRt}, \cs{BR}, \cs{BRs}, and
% \cs{BRpm} for residual (departure) properties. These produce, respectively,
% $\Bt, \Bm, \Bs, \Bpm{i}, \BEt, \BE, \BEs, \BEpm{i}, \BRt, \BR, \BRs,$ and
% $\BRpm{i}$ using the defaults.
%
% \subsection{Other Predefined Symbols and Modifiers}
% There are a number of predefined symbols and modifiers.
% While these symbols could be defined or used without these macros, such use
% is not recommended: changing package options will result in inconsistencies
% if these macros are not used.
%
% \subsubsection{Heat Capacities, Compressibilities, and Expansivities}
% \DescribeMacro{\cP}
% \DescribeMacro{\cV}
% \DescribeMacro{\kappaS}
% \DescribeMacro{\kappaT}
% \DescribeMacro{\alphaP}
% \DescribeMacro{\alphaS}
% The isobaric and isochoric heat capacities are produced with \cs{cP} and
% \cs{cV}, respectively. Four other measurable quantities are defined: the
% isothermal and isentropic compressibilities, \cs{kappaT} and \cs{kappaS},
% respectively; and the isobaric and isentropic volume expansivities,
% \cs{alphaP} and \cs{alphaS}, respectively. Some textbooks use $\beta$ instead
% of $\alpha$ for the volume expansivity to differentiate it from the
% \emph{linear} expansivity; this can be changed by redefining
% \cs{expansivitysymbol}, which is done automatically by some of the
% package options that create notation specific to a particular textbook.
%
% \subsubsection{Joule--Thomson Coefficients}
% \changes{v2.00}{2023/11/16}{Added \cs{muJT} to represent Joule--Thomson
% coefficients (which have different notation across textbooks).}
% \DescribeMacro{\muJT}
% The Joule--Thomson coefficient is produced with \cs{muJT}, which be default
% is rendered $\muJT$. Some books call this coefficient $\alpha_H$; this is
% handled automatically for books of which the package author is aware.
%
% \subsubsection{Fugacities and Fugacity Coefficients}
% \DescribeMacro{\fpure}
% \DescribeMacro{\fmix}
% \DescribeMacro{\phipure}
% \DescribeMacro{\phimix}
% Different textbooks use different variations on the symbol $f$ for
% fugacity, so it is recommended to use the macro \cs{fpure} to denote the
% pure-component fugacity and \cs{fmix} to denote the mixture fugacity.
% Similarly, the pure-component fugacity coefficient should be generated with
% \cs{phipure}, and that in the mixture should be \cs{phimix}.
%
% For example, the following markup is an example of a common equation in
% mixture thermodynamics:
% \begin{verbatim}
% \[ \fmix_j = x_j \phimix_j P = x_j \gamma_j \fpure_j
% = x_j \gamma_j \phipure_j P. \]
%\end{verbatim}
% With the default package options, this produces
% \[ \fmix_j = x_j \phimix_j P = x_j \gamma_j \fpure_j
% = x_j \gamma_j \phipure_j P. \]
% With the |Thompson| package option, however, the same markup produces
% \[ \hat f_j = x_j \hat\phi_j P = x_j \gamma_j f^\bullet_j
% = x_j \gamma_j \phi^\bullet_j P. \]
% Similarly, the |Prausnitz| package option causes it to generate
% \[ f_j = x_j \phi_j P = x_j \gamma_j f_{\text{pure},j}
% = x_j \gamma_j \phi_{\text{pure},j} P, \]
% and the |Sandler| option causes it to generate
% \[ \bar f_j = x_j \bar \phi_j P = x_j \gamma_j f_j
% = x_j \gamma_j \phi_j P. \]
%
% \subsubsection{Activity Coefficients and Henry's Constants}
% \DescribeMacro{\gammarat}
% \DescribeMacro{\gammamol}
% \DescribeMacro{\Henryrat}
% \DescribeMacro{\Henrymol}
% The activity coefficient based on the Lewis--Randall rule can be generated
% with \cs{gamma}, as usual. The Henry's Law activity coefficients should be
% produced with \cs{gammarat} (rational basis) and \cs{gammamol} (molal basis).
% There are also macros to generate the Henry's law constants for both the
% rational basis (\cs{Henryrat}) and the molal basis (\cs{Henrymol}).
% These are interrelated:
% \begin{verbatim}
% \[ \fmix_i = x_i \gamma_i \fpure_i = x_i \gammarat_i \Henryrat_i
% = C_i \gammamol_i \Henrymol_i \]
%\end{verbatim}
% produces
% \[ \fmix_i = x_i \gamma_i \fpure_i = x_i \gammarat_i \Henryrat_i
% = C_i \gammamol_i \Henrymol_i \]
% using the default options.
% These symbols can be customized either directly or by using package options.
% For example, the |TesterModell| package option changes the equation
% above to
% \[ \hat f_i = x_i \gamma_i f_i = x_i \gamma_i^{**} f_i^{**}
% = C_i \gamma_i^* f_i^* \]
% without any changes in markup.
%
% Note that some books (e.g., |ElliottLira|) prefer the atmospheric chemistry
% convention for the molal basis, namely
% \[ \fmix_i = x_i \gamma_i \fpure_i = x_i \gammarat_i \Henryrat_i
%%^^A = C_i \gammamol_i \Henrymol_i
% = C_i \gammamol_i / K_{H,i} \]
% (that is, using $1/K_{H,i}$ in place of $\Henrymol_i$).
% Unfortunately, this makes it impossible to change symbols without any edits
% to markup, so this convention is \emph{not} supported by this package.
%
% \subsubsection{Saturation Properties}
% \DescribeMacro{\Psat}
% \DescribeMacro{\Pvap}
% \DescribeMacro{\fsat}
% \DescribeMacro{\phisat}
% The saturation pressure is generated with \cs{Psat}. The macro \cs{Pvap} is
% an alias for \cs{Psat}. The fugacity and fugacity coefficient at saturation
% are accessed via \cs{fsat} and \cs{phisat}, respectively. Package options
% can be used to change some of these to match the notation of specific
% textbooks.
%
% \DescribeMacro{\sat}
% The \cs{sat} macro is used ``behind the scenes'' as part of
% \cs{Psat}, \cs{fsat}, and \cs{phisat}, which produce $\Psat$,
% $\fsat$, and $\phisat$, respectively (using the defaults). If you wanted to
% redefine them to be $P^\text{vap}$, $f^\text{vap}$, and $\phi^\text{vap}$,
% you could simply redefine \cs{sat} with
% \verb"\RenewDocumentCommand{\sat}{}{{\text{vap}}}".
% This is done automatically using package option |Sandler|.
%
% \subsubsection{Standard States}
% \DescribeMacro{\std}
% \DescribeMacro{\Pstd}
% \DescribeMacro{\fstd}
% The symbol $\circ$ (\cs{circ}) is used by default for standard states.
% This is intended to be easy to change should the user want to replace
% $P^\circ$ with $P^\ominus$, say. This is accessed via the \cs{std} macro.
% The macro \cs{Pstd} is defined as |P^\std| for convenience to denote
% standard pressures, and \cs{fstd} is defined for standard fugacities so as
% to ease implementation across textbooks.
%
% The usual usage would be something like this:
% \begin{verbatim}
% \[ \Deltarxn\Gm = \sumall_i \nu_i \mu_i = \sumall_i \left[ \nu_i \mu^\std_i
% + \nu_i RT \log\left(\frac{\fmix_i}{\fstd_i}\right) \right]
% = \Deltarxn\Gm^\std + RT \log\left[\prodall_i a_i^{\nu_i} \right] \],
%\end{verbatim}
% which produces
% \[ \Deltarxn\Gm = \sumall_i \nu_i \mu_i = \sumall_i \left[ \nu_i \mu^\std_i
% + \nu_i RT \log\left(\frac{\fmix_i}{\fstd_i}\right) \right]
% = \Deltarxn\Gm^\std + RT \log\left[\prodall_i a_i^{\nu_i} \right] \]
% with the default settings.
%
% \subsubsection{Changes on Mixing, Reaction, Fusion, Vaporization, and
% Sublimation}
% \DescribeMacro{\Deltamix}
% Mixing properties are handled via the \cs{Deltamix} macro, and are used as in
% the following example:
% \begin{verbatim}
% \[ \Deltamix\Gm = \Gm - \sumall_i x_i \Gm_i
% = \Deltamix\Hm - T\Deltamix\Sm \],
%\end{verbatim}
% which yields, using the default options,
% \[ \Deltamix\Gm = \Gm - \sumall_i x_i \Gm_i = \Deltamix\Hm - T\Deltamix\Sm \]
% Some textbooks (|Sandler|, |Thompson|) choose to typeset these with the word
% ``mix'' \emph{before} the symbol, which is handled automatically by this
% package.
% \DescribeMacro{\mixing}
% The macro \cs{mixing} determines how the change in mixing label is rendered;
% the default is \verb"{\text{mix}}".
%
% \DescribeMacro{\Deltafus}
% \DescribeMacro{\Deltasub}
% \DescribeMacro{\Deltavap}
% The commands \cs{Deltafus}, \cs{Deltasub}, and \cs{Deltavap}
% typeset changes due to fusion (melting), sublimation (subliming), and
% vaporization (boiling), respectively. Their use is straightforward, viz.,
% \begin{verbatim}
% \[ \Deltasub\Hm = \Hm^V - \Hm^S = \Hm^V - \Hm^L + (\Hm^L - \Hm^S)
% = \Deltafus\Hm + \Deltavap\Hm \],
%\end{verbatim}
% yielding
% \[ \Deltasub\Hm = \Hm^V - \Hm^S = \Hm^V - \Hm^L + (\Hm^L - \Hm^S)
% = \Deltafus\Hm + \Deltavap\Hm \]
% with the default options. Note that some textbooks (e.g., |Sandler|) typeset
% these quantities quite differently; this is handled automatically. Other
% textbooks (e.g., |Koretsky|) typeset them as subscripts; this is also
% handled automatically.
%
% \DescribeMacro{\Deltaf}
% \DescribeMacro{\Deltarxn}
% The macros \cs{Deltaf} and \cs{Deltarxn} are intended to typeset the enthalpy
% or free energy of formation and reaction, respectively. For example,
% \begin{verbatim}
% \[ \Deltarxn\Hm^\std = \sumall_i \nu_i \Deltaf\Hm_i^\std \]
%\end{verbatim}
% results in
% \[ \Deltarxn\Hm^\std = \sumall_i \nu_i \Deltaf\Hm_i^\std. \]
% It is not anticipated that this command will be combined with something like
% a heat capacity, which already has a (potentially double) subscript, but as
% there is no ``formation'' heat capacity, that should not present a problem.
%
% \subsection{Residual and Excess Properties}
% \DescribeMacro{\UR}
% \DescribeMacro{\URt}
% \DescribeMacro{\URs}
% \DescribeMacro{\URpm}
% \DescribeMacro{\UE}
% \DescribeMacro{\UEt}
% \DescribeMacro{\UEs}
% \DescribeMacro{\UEpm}
% Additional macros are defined that make it easy to typeset the residual
% (also called ``departure'') and excess total, molar, specific, and partial
% molar properties. These macros follow the same pattern: \cs{UR}, \cs{URt},
% \cs{URs}, and \cs{URpm} typeset the molar, total, specific, and partial molar
% residual internal energies, respectively, and by default expand to $U^R,$
% $\URt,$ $\URs, $ and $\smash[t]{\URpm{i}}$ (the last
% is called as \verb"\URpm{i}" or \verb"\URpm_i"). Similarly, \cs{UE},
% \cs{UEt}, \cs{UEs}, and \cs{UEpm} typeset the corresponding excess
% properties. The first character of the macros for other properties follow the
% same pattern as in Table~\ref{table:symbols}.
%
% The $R$ and $E$ characters are generated by the macros \cs{residual} and
% \cs{excess}, respectively. These macros can be redefined; for example, if you
% \DescribeMacro{\excess}
% \DescribeMacro{\residual}
% want \cs{SE}, which normally produces $\SE$, to give you $S^{EX}$---and let's
% be honest, who doesn't want that?\footnote{You knew that joke was
% coming.}---then you can redefine it with
% \begin{verbatim}
% \RenewDocumentCommand{\excess}{}{{EX}},
%\end{verbatim}
% or possibly
% \begin{verbatim}
% \RenewDocumentCommand{\excess}{}{{\mathrm{EX}}}
%\end{verbatim}
% or even
% \begin{verbatim}
% \RenewDocumentCommand{\excess}{}{\text{EX}},
%\end{verbatim}
% which cause \cs{SE} to expand to $S^{EX},$ $S^\mathrm{EX},$ and
% $S^\text{EX},$ respectively.
%
% It is generally possible to use superscripts with the excess or residual
% properties; in the event this fails, the \cs{excess} and \cs{residual} macros
% can be used directly, viz.,
% \begin{verbatim}
% \begin{gather*}
% \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
% = \HR(T,\Pstd) - \HR^\IS(T,\Pstd) = \HR^\std - \HR^{\IS,\std} \\
% \RenewDocumentCommand{\excess}{{EX}}
% \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
% = \HR(T,\Pstd) - \HR^\IS(T,\Pstd)
% \end{gather*},
%\end{verbatim}
% which yields
% \begin{gather*}
% \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
% = \HR(T,\Pstd) - \HR^\IS(T,\Pstd) = \HR^\std - \HR^{\IS,\std} \\
% \RenewDocumentCommand{\excess}{}{{EX}}
% \HE^\std = \Hm^{\excess,\std} = \HE(T,\Pstd)
% = \HR(T,\Pstd) - \HR^\IS(T,\Pstd)
% \end{gather*}
% using the default options.
%
% \subsection{Partial Derivatives}
% \DescribeMacro{\Partial}%
% \DescribeMacro{\Partial*}%
% Partial derivatives are easily rendered using the \cs{Partial} command.
% There is a starred form (\cs{Partial*}) that additionally adjusts the
% spacing after the closing symbol to remove some of the space, anticipating
% that the following binary operator will overhang the subscripts.
% Compare the following:
% \begin{verbatim}
% \[ \Partial{\Hm}{T}{P} = \cP \qquad \Partial*{\Hm}{T}{P} = \cP \],
%\end{verbatim}
% which yields
% \[ \Partial{\Hm}{T}{P} = \cP \qquad \Partial*{\Hm}{T}{P} = \cP. \]
%
% \DescribeMacro{\Partialinline}%
% Inline first derivatives\footnote{The ``inline'' versions of
% partial derivatives are ``sticky'': if you issue \cs{Partialinline} or
% its second-order equivalents anywhere in a line, all subsequent
% \cs{Partial} and \cs{Partial[Mix]Second} macros on the same line
% (technically, anywhere in the same \TeX\ ``group'') will
% expand inline as well. To prevent this, enclose your \cs{Partialinline} and
% associated arguments in its own group (i.e.,
% \texttt{\{\cs{Partialinline}\dots\}}).%
% \label{fn:inline}}
% can be entered the same way; compare:
% \begin{verbatim}
% \[ \Partial*{\Hm}{T}{P} = \Partialinline{\Hm}{T}{P}
% = T\Partial{\Sm}{T}{P} \],
%\end{verbatim}
% which results in
% \[ \Partial*{\Hm}{T}{P} = \Partialinline{\Hm}{T}{P}
% = T\Partial{\Sm}{T}{P}. \]
% There is no need for an inline starred form, as the subscripts do not
% extend far enough below the baseline.
%
% \subsubsection{Second-Order Partial Derivatives}
% \DescribeMacro{\PartialSecond}%
% \DescribeMacro{\PartialSecond*}%
% \DescribeMacro{\PartialMixSecond}%
% \DescribeMacro{\PartialMixSecond*}%
% Second partial derivatives and mixed-second partial derivatives are typeset
% with the commands \cs{PartialSecond} and \cs{PartialMixSecond}, respectively.
% Like the first-order variety, these also have starred versions that remove
% the space immediately following the closing symbols, anticipating that the
% equals sign or other binary operator following the derivative will overhang
% the elements held constant. For example,
% \begin{verbatim}
% \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \Partial{\Gpm_i}{P}{T,\allNs} \]
%\end{verbatim}
% looks like
% \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \PartialMixSecond*{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \PartialMixSecond*{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \Partial{\Gpm_i}{P}{T,\allNs}. \]
% \DescribeMacro{\PartialSecondinline}%
% \DescribeMacro{\PartialMixSecondinline}%
% Inline versions\footref{fn:inline} of second-order derivatives are handled
% with \cs{PartialSecondinline} and \cs{PartialMixSecondinline}, viz.,
% \begin{verbatim}
% \begin{equation}
% \Vpm_i = \Partialinline{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \PartialMixSecondinline{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \PartialMixSecondinline{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \Partialinline{\Gpm_i}{P}{T,\allNs} \]
% \end{equation}
%\end{verbatim}
% looks like
% \begin{equation}
% \Vpm_i = \Partialinline{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \PartialMixSecondinline{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \PartialMixSecondinline{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \Partialinline{\Gpm_i}{P}{T,\allNs}.
% \label{eq:Vpm-inline}
% \end{equation}
% \pagebreak[0]%
%
% \subsubsection{Delimiter Sizing}
% \DescribeMacro{\PartialBigg}%
% \DescribeMacro{\PartialSecondBigg}%
% \DescribeMacro{\PartialMixSecondBigg}%
% \DescribeMacro{\Partialbigg}%
% \DescribeMacro{\PartialSecondbigg}%
% \DescribeMacro{\PartialMixSecondbigg}%
% There are instances (such as the line above) when \cs{Partial} causes
% parentheses that are slightly
% too tall but do not need to be---particularly when partial molar properties,
% specific quantities, or fugacities are involved. The macro \cs{PartialBigg}
% uses \pkg{amsmath}'s \tn{Biggl} and \tn{Biggr} macros in place of \tn{left}
% and \tn{right} to size the delimiters accordingly; \cs{Partialbigg} uses
% \tn{biggl} and \tn{biggr} in a similar fashion. For example, compare the
% following:
% \begin{verbatim}
% \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial*{\Gpm_i}{P}{T,\allNs}
% = \PartialBigg*{\Gpm_i}{P}{T,\allNs}
% = RT\Partial*{\log\fmix_i}{P}{T,\allNs}
% = RT\,\PartialBigg*{\log\fmix_i}{P}{T,\allNs}
% = RT\,\Partialbigg{\log\fmix_i}{P}{T,\allNs} \],
%\end{verbatim}
% which typesets as
% \[ \Vpm{i} = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial*{\Gpm{i}}{P}{T,\allNs}
% = \PartialBigg*{\Gpm{i}}{P}{T,\allNs}
% = RT\Partial*{\log\fmix_i}{P}{T,\allNs}
% = RT\,\PartialBigg*{\log\fmix_i}{P}{T,\allNs}
% = RT\,\Partialbigg{\log\fmix_i}{P}{T,\allNs}. \]
% Note that a similar effect---possibly with other side effects---can be
% achieved with \pkg{amsmath}'s \tn{smash} command, which has the effect of
% removing all vertical space associated with a particular character.
% Observe:
% \begin{verbatim}
% \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\smash{\Gpm_i}}{P}{T,\allNs} \]
%\end{verbatim}
% produces
% \[ \Vpm_i = \Partial*{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\smash{\Gpm_i}}{P}{T,\allNs}. \]
%
% \setmarginparsize{\footnotesize}%
% \DescribeMacro{\Partialinlinetext}%
% \DescribeMacro{\PartialSecondinlinetext}%
% \restoremarginparsize
% \setmarginparsize{\scriptsize}
% \DescribeMacro{\PartialMixSecondinlinetext}%
% \restoremarginparsize
% Similarly, there are times when \cs{Partialinline} causes parentheses that
% are too big for inline text, and they do not need to be---particularly for
% symbols with overlines, underlines, or other decorations. In this case, the
% macros \cs{Partialinlinetext}, \cs{PartialSecondinlinetext}, and
% \cs{PartialMixSecondinlinetext} come in handy; using these macros like so,
% \begin{verbatim}
% \[ \Vpm_i = \Partialinlinetext{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \PartialMixSecondinlinetext{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \PartialMixSecondinlinetext{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \Partialinlinetext{\Gpm_i}{P}{T,\allNs} \],
%\end{verbatim}
% Equation~\eqref{eq:Vpm-inline} looks like
% \[ \Vpm{i} = \Partialinlinetext{\Vt}{\Nt_i}{T,P,\allNsbut{i}}
% = \PartialMixSecondinlinetext{\Gt}{\Nt_i}{P}{T,\allNsbut{i}}
% = \PartialMixSecondinlinetext{\Gt}{P}{\Nt_i}{T,\allNsbut{i}}
% = \Partialinlinetext{\Gpm{i}}{P}{T,\allNs}. \]
%
% \subsubsection{Higher-Order Derivatives}
% It is possible to ``fake'' higher-order derivatives via some trickery.
% For example,
% \begin{verbatim}
% \[ \cPpm_i = T\Partial*{\Spm_i}{T}{P,\allXs}
% = T\PartialMixSecond*{\St}{T}{\Nt_i}{P,\allNsbut{i}}
% = -T\Partial{^3\Gt}{T^2\partial\Nt_i}{P,\allNsbut{i}} \]
%\end{verbatim}
% gives
% \[ \cPpm{i} = T\Partial*{\Spm{i}}{T}{P,\allXs}
% = T\PartialMixSecond*{\St}{T}{\Nt_i}{P,\allNsbut{i}}
% = -T\Partial{^3\Gt}{T^2\partial\Nt_i}{P,\allNsbut{i}}, \]
% which is probably pretty close to what you wanted. Using this trickery with
% the package option \verb"nosubscripts" will not work, and the use of
% third- and higher-order derivatives with this package should generally be
% considered unsupported.
%
% \subsection{Holding Constant the Number of Moles of Several Species}
% \DescribeMacro{\allNs}%
% \DescribeMacro{\allNsbut}%
% \DescribeMacro{\allmus}%
% \DescribeMacro{\allmusbut}%
% \DescribeMacro{\allXs}%
% \DescribeMacro{\allXsbut}%
% \DescribeMacro{\allYs}%
% \DescribeMacro{\allYsbut}%
% \DescribeMacro{\allMs}%
% \DescribeMacro{\allMsbut}%
% \DescribeMacro{\allWs}%
% \DescribeMacro{\allWsbut}%
% It is common in thermodynamics to use notation such as
% \[ \Vpm_k = \Partial{\Vt}{\Nt_k}{T,P,\allNsbut{k}}, \]
% or perhaps
% \begin{thermomolesrange}
% \[ \Vpm{k} = \Partial{\Vt}{\Nt_k}{T,P,\allNsbut{k}} \]
% \end{thermomolesrange}
% or
% \[ \Vpm{k} = \left(\frac{\partial\Vt}{\partial\Nt_k}\right)_{T,P,\Nt_j[k]} \]
% to mean partial derivatives that hold the number of moles of each species
% constant \emph{except} the one being changed.
% Similarly, a property determined with all mole fractions held
% constant might be written
% \[ \cP = \Partial{\Hm}{T}{P,\allXs}, \]
% or perhaps
% \begin{thermomolesrange}\relax
% \[ \cP = \Partial{\Hm}{T}{P,\allXs}. \]
% \end{thermomolesrange}\relax
% There are several macros that standardize such constructs.
% The \cs{allNs} macro expands to something meaning the number of moles of all
% species; by default, this is $\vec{n}$ (package option
% \verb"moles-index"), but can be changed to $n_1,\dotsc,n_C$ using the package
% option \verb"moles-range". Similarly, the macros \cs{allmus} and
% \cs{allmusbut} do the same but with $n$ replaced by $\mu$, and \cs{allMsbut}
% is the same with $m$ instead of $n$. There are analogous macros for mole
% fractions, namely \cs{allXs} and \cs{allXsbut} for $x$ and \cs{allYs} and
% \cs{allYsbut} for $y$, as well as \cs{allWs} and \cs{allWsbut} for mass
% fractions---these implicitly assume that all mole or mass fractions
% \emph{except} the last are used as variables.
% These macros all take an optional argument; for example,
% \begin{verbatim}
% \[ \Partial{\Ht}{\Nt_1}{T,P,\allNsbut{1}} =
% \Partial{\Ht}{\Nt_1}{T,P,\allNsbut[m]{1}} = \Hpm_1 \]
%\end{verbatim}
% typesets as
% \[ \Partial{\Ht}{\Nt_1}{T,P,\allNsbut{1}} =
% \Partial{\Ht}{\Nt_1}{T,P,\allNsbut[m]{1}} = \Hpm{1}. \]
% Similarly,
% \begin{verbatim}
% \[ \Partial{\Hm}{x_i}{T,P,\allXsbut{i}}
% = \Partial{\Hm}{x_i}{T,P,\allXsbut[m]{i}}
% = \Hpm_i - \Hpm_\ncomponents \]
%\end{verbatim}
% becomes
% \[ \Partial{\Hm}{x_i}{T,P,\allXsbut{i}}
% = \Partial{\Hm}{x_i}{T,P,\allXsbut[m]{i}}
% = \Hpm{i} - \Hpm{\ncomponents}. \]
% Users must supply their own redefinitions if they wish to hold something
% other than \cs{ncomponents} constant in addition to the argument for mole
% and mass fractions.
% Using the \verb"moles-range" package option, for which \verb"\allXsbut{k}"
% expands to
% \( \begin{thermomolesrange}\allXsbut{k}\end{thermomolesrange} \)
% rather than \( \allXsbut{k} \), the optional argument is ignored.
%
% The optional argument to \cs{allNs} and similar commands is ignored when
% using the default options; it is relevant for package options that redefine
% \cs{allNs} to make $N_i$, for example; in this case, one can enter
% \cs{allNs[j]} to make \TeX\ render $N_j$ instead of $N_i$. This is useful
% if you are using $i$ somewhere else in the equation.
%
% \DescribeMacro{\allbut}
% \DescribeMacro{\allbutlastand}
% Users can define new ``all but'' macros using the \cs{allbut} and
% \cs{allbutlastand} commands. For example,
% \begin{verbatim}
% \NewDocumentCommand{\allNsbut}{O{j} m}{\allbut[#1]{#2}{\Nt}}
% \NewDocumentCommand{\allXsbut}{O{j} m}{\allbutlastand[#1]{#2}{x}}
%\end{verbatim}
% are the definitions of \cs{allNsbut} and \cs{allXsbut}, respectively.
%
% \subsection{Jacobians}
% \DescribeMacro{\Jacobian}%
% \DescribeMacro{\Jacobiandet}%
% The Jacobian determinant is often denoted with Leibnitz-like notation, viz.,
% \begin{verbatim}
% \[ \Jacobian{K,L}{X,Y} = \Jacobiandet{K,L}{X,Y} \],
%\end{verbatim}
% which produces (assuming the \pkg{amsmath} package has been loaded)
% \[ \Jacobian{K,L}{X,Y} = \Jacobiandet{K,L}{X,Y}. \]
% There are two optional arguments to \cs{Jacobiandet}. The first will be
% pre-pended before every element of the matrix (typically \cs{textstyle} or
% \cs{displaystyle}); the second is the extra spacing added between rows
% (default is 1.25~ex for text-style fractions and 2.75~ex for display-style
% fractions). More than two variables can be specified, viz.,
% \begin{verbatim}
% \[ \Jacobian{K,L,M}{X,Y,Z}
% = \Jacobiandet[\displaystyle][3ex]{K,L,M}{X,Y,Z} \]
%\end{verbatim}
% will produce
% \[ \Jacobian{K,L,M}{X,Y,Z} = \Jacobiandet[\displaystyle][3ex]{K,L,M}{X,Y,Z}.
% \]
% The \cs{Jacobiandet} macro will understand implied multicomponent Jacobians,
% too, namely,
% \begin{verbatim}
% \[ \Jacobian{f_1,\dots,f_m}{x_1,\dots,x_m} =
% \Jacobiandet{f_1,\dots,f_m}{x_1,\dots,x_m} \]
%\end{verbatim}
% typesets as
% \[ \Jacobian{f_1,\dots,f_m}{x_1,\dots,x_m} =
% \Jacobiandet{f_1,\dots,f_m}{x_1,\dots,x_m}. \]
% If the option |moles-range| or the \env{thermomolesrange} environment is
% used, the same code produces
% \begin{thermomolesrange}
% \[ \Jacobian{f_1,\dots,f_m}{x_1,\dots,x_m} =
% \Jacobiandet{f_1,\dots,f_m}{x_1,\dots,x_m}. \]
% \end{thermomolesrange}
%
% \subsection{Sums and Products}
% \DescribeMacro{\sumall}
% \DescribeMacro{\sumallbutlast}
% \DescribeMacro{\prodall}
% It is common to require sums and products such as
% \[ \sumall_i x_i = 1 \quad \text{or} \quad
% x_\ncomponents = 1 - \sumallbutlast_i x_i \quad \text{or} \quad
% \Gt = \sumall_j \mu_j\Nt_j \quad \text{and} \quad
% K = \prodall_k a_k^{\nu_k}. \]
% This package defines shortcuts to typeset such terms thus:
% \begin{verbatim}
% \[ \sumall_i x_i = 1 \quad \text{or} \quad
% x_\ncomponents = 1 - \sumallbutlast_i x_i \quad \text{or} \quad
% \Gt = \sumall_j \mu_j\Nt_j \quad \text{and} \quad
% K = \prodall_k a_k^{\nu_k} \].
%\end{verbatim}
% The symbol $C$ can be changed by redefining the expandable macro
% \cs{ncomponents}. This is done automatically by some package options (e.g.,
% |TesterModell| changes it to $n$; |Sandler| changes it to $\mathcal{C}$;
% |Thompson| changes it to $c$).
%
% \section{Loading the Package} \label{sec:loading}
% To load the package with the defaults enabled, load it the usual way:
% \begin{verbatim}
% \usepackage{thermodynamics}
%\end{verbatim}
% The package options loaded by default are \verb"EUAGHan", \verb"subscripts",
% \verb"parentheses", \verb"intensive-plain", and \verb"moles-index".
% These define, respectively, the default symbols to use for total energy,
% internal energy, Helmholtz free energy, and so forth; the manner of writing
% partial derivatives; the delimiters around partial derivatives; the
% manner of denoting extensive, molar, and specific properties; and the
% manner of writing the number of moles of all or most species in partial
% derivatives. The default behavior can be altered by options in the following
% section.
%
% \subsection{Package Options}
% There are three categories of options: options that affect which symbols are
% used, options that affect how symbols are decorated, and options that affect
% how partial derivatives are displayed. These are presented in turn.
%
% \subsubsection{Options that Change Symbol Sets}
% There are several options that choose the set of symbols to use for total
% energy, internal energy, Helmholtz free energy, and so forth. These are
% summarized in Table~\ref{table:symbol-sets}. The default is \verb"EUAGHan".
%
% \NewExtensiveProperty{f}{F}
% \NewExtensiveProperty{a}{A}
% \NewExtensiveProperty{ee}{\mathcal{E}}
% \NewExtensiveProperty{aa}{\mathcal{A}}
% \begin{table}
% \caption{Options controlling which symbols to use by default. The
% macros \cs{Et}, \cs{Ut}, \cs{Ft}, \cs{Gt}, \cs{Ht}, \cs{At}, and
% \cs{Nt} represent the total energy, internal energy,
% Helmholtz free energy, Gibbs free energy, enthalpy, surface area,
% and number of moles, respectively. Symbols are shown as they would
% appear with the (default) option \texttt{intensive-plain}.
% }
% \label{table:symbol-sets}
% \centering\small
% \begin{tabular}{l l l l l l l l l}
% \toprule
% Option & \verb"\Et" & \verb"\Ut" & \verb"\Ft" & \verb"\Gt" & \verb"\Ht"
% & \verb"\At" & \verb"\Nt" \\
% \midrule
% |EUAGHan| & $\Et$ & $\Ut$ & $\Ft$ & $\Gt$ & $\Ht$ & $\At$ & $n$ \\
% |EUAGHaN| & $\Et$ & $\Ut$ & $\Ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
% |EUHAGan| & \multicolumn{7}{l}{(synonym for \texttt{EUAGHan})} \\
% |EUHAGaN| & \multicolumn{7}{l}{(synonym for \texttt{EUAGHaN})} \\
% |EUFGHAn| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $n$ \\
% |EUFGHAN| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $N$ \\
% |EEFGHAn| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $n$ \\
% |EEFGHAN| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\at$ & $N$ \\
% |EEFGHan| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $n$ \\
% |EEFGHaN| & $\eet$ & $\Et$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
% |EEAGHaN| & $\eet$ & $\Et$ & $\Ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
% |EEAGHAN| & $\eet$ & $\Et$ & $\Ft$ & $\Gt$ & $\Ht$ & $\aat$ & $n$ \\
% |EUAGHAN| & $\Et$ & $\Ut$ & $\Ft$ & $\Gt$ & $\Ht$ & $\aat$ & $N$ \\
% |EUFGHan| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $n$ \\
% |EUFGHaN| & $\Et$ & $\Ut$ & $\ft$ & $\Gt$ & $\Ht$ & $\At$ & $N$ \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% Using \verb"EUAGHan" (the default), we might use the following markup:
% \begin{verbatim}
% \[ \Ft = \Ut - T\St = -P\Vt + \sumall_i \mu_i \Nt_i + \sigma \At
% \qquad \Hm = \Um + P\Vm \qquad \Et = \Ut + \frac12 mv^2 \],
%\end{verbatim}
% which would look like
% \[ \Ft = \Ut - T\St = -P\Vt + \sumall_i \mu_i \Nt_i + \sigma \At
% \qquad \Hm = \Um + P\Vm \qquad \Et = \Ut + \frac12 mv^2 \]
% Using the \verb"EEFGHAN" option, the same markup would yield
% \[ \ft
% = \Et - T\St
% = -P\Vt + \sumall_i \mu_i N_i + \sigma \at
% \qquad H = U + PV
% \qquad \eet = \Et + \frac12 mv^2. \]
%
% \subsubsection{Options for Extensive vs.\ Molar Properties}
% There are four sets of notation that define how extensive properties are
% represented, as shown in Table~\ref{table:extensive}.
% The default is \verb"intensive-plain", which (using the volume as an
% example) represents the total, molar, specific, and partial molar volumes,
% respectively, as $\Vt,$ $\Vm,$ $\Vs,$ and $\Vpm{j},$
% respectively.
%
% For example, the definition of the partial molar enthalpy would be different
% depending on which set of notation is used. The markup
% \begin{verbatim}
% \[ \Hpm_i = \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}} \]
%\end{verbatim}
% yields the following, depending on the package option loaded:
% \begin{align*}
% \Hpm_i &= \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% && \text{\texttt{intensive-plain}} \\
% \Hpm_i &=
% \begin{thermoextensiveplain}
% \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% \end{thermoextensiveplain}
% && \text{\texttt{extensive-plain}} \\
% \Hpm_i &=
% \begin{thermoextensivesuperscript}
% \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% \end{thermoextensivesuperscript}
% && \text{\texttt{extensive-superscript}} \\
% \begin{thermointensivelowercase}
% \Hpm_i
% \end{thermointensivelowercase}
% &=
% \begin{thermointensivelowercase}
% \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
% = \Partial{\Nt\Hm}{\Nt_i}{T,P,\allNsbut{i}}
% \end{thermointensivelowercase}
% && \text{\texttt{intensive-lowercase}}
% \end{align*}
% The use of \verb"intensive-lowercase" is strongly discouraged.
%
% Note that the number of moles can be changed from $n$ to $N$ via the
% options in the previous section.
%
% \begin{table}
% \caption{Notation sets that can be set using the options
% \texttt{intensive-plain} (the default), \texttt{extensive-plain},
% \texttt{extensive-superscript}, and \texttt{intensive-lowercase}.}
% \label{table:extensive}
% \centering\small
% \begin{tabular}{l l l l l l}
% \toprule
% Option & \verb"\Vt" & \verb"\Vm" & \verb"\Vs" & \verb"\Vpm_i" \\
% \midrule
% \verb"intensive-plain" & $\Vt$ & $\Vm$ & $\Vs$ & $\Vpm{i}$ \\[2ex]
% \verb"extensive-plain" &
% \begin{thermoextensiveplain}$\Vt$\end{thermoextensiveplain} &
% \begin{thermoextensiveplain}$\Vm$\end{thermoextensiveplain} &
% \begin{thermoextensiveplain}$\Vs$\end{thermoextensiveplain} &
% \begin{thermoextensiveplain}$\Vpm{i}$\end{thermoextensiveplain}
% \\[2ex]
% \verb"extensive-superscript" &
% \begin{thermoextensivesuperscript}$\Vt$\end{thermoextensivesuperscript} &
% \begin{thermoextensivesuperscript}$\Vm$\end{thermoextensivesuperscript} &
% \begin{thermoextensivesuperscript}$\Vs$\end{thermoextensivesuperscript} &
% \begin{thermoextensivesuperscript}$\Vpm{i}$\end{thermoextensivesuperscript} \\[2ex]
% \verb"intensive-lowercase" &
% \begin{thermointensivelowercase}$\Vt$\end{thermointensivelowercase} &
% \begin{thermointensivelowercase}$\Vm$\end{thermointensivelowercase} &
% \begin{thermointensivelowercase}$\Vs$\end{thermointensivelowercase} &
% \begin{thermointensivelowercase}$\Vpm{i}$\end{thermointensivelowercase}
% \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \pagebreak[1]\relax
% \setmarginparsize{\footnotesize}
% \DescribeEnv{thermointensiveplain}
% \DescribeEnv{thermoextensiveplain}
% \DescribeEnv{thermoextensivesuperscript}
% \DescribeEnv{thermointensivelowercase}
% \restoremarginparsize
% It is possible to change notation locally, though there are very, very few
% good reasons why you would want to do this in a regular document---normally,
% one would use the corresponding package options. The environment
% \env{thermointensiveplain} means \cs{St} will become $\St$ and \cs{Sm} will
% become $\Sm$ in the text. Similarly, inside \env{thermoextensiveplain},
% \cs{St} will become $S$ and \cs{Sm} will become $\St$.
% Inside \env{thermoextensivesuperscript}, \cs{St} will become $S^t$ and
% \cs{Sm} will be $S$; and inside \env{thermointensivesubscript},
% \cs{St} will be $S$ and \cs{Sm} will be $s$.
%
% \subsubsection{Options Affecting Partial Derivatives}
% There are several options that change how partial derivatives are rendered.
% First are the options that affect the delimiters. We will use the following
% code as an example:
% \begin{verbatim}
% \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
% = \PartialMixSecond{\Gm}{P}{T}{}
% = -\Partial{\Sm}{P}{T}. \]
%\end{verbatim}
% Using the |parentheses| option (the default), this gives
% \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
% = \PartialMixSecond{\Gm}{P}{T}{}
% = -\Partial{\Sm}{P}{T}. \]
% The option |brackets| changes the output to
% \begin{thermobrackets}
% \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
% = \PartialMixSecond{\Gm}{P}{T}{}
% = -\Partial{\Sm}{P}{T}. \]
% \end{thermobrackets}\relax
% The option \verb"bar" changes the output to
% \begin{thermobar}
% \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
% = \PartialMixSecond{\Gm}{P}{T}{}
% = -\Partial{\Sm}{P}{T}. \]
% \end{thermobar}\relax
% The option \verb"plain-derivatives" eliminates all delimiters; this forces
% the \verb"nosubscripts" option. The output in this case is
% \begin{thermoplain}%
% \[ \Partial*{\Vm}{T}{P} = \PartialMixSecond{\Gm}{T}{P}{}
% = \PartialMixSecond{\Gm}{P}{T}{}
% = -\Partial{\Sm}{P}{T}. \]
% \end{thermoplain}\relax
% Accompanying the \verb"plain-derivatives" option is the \verb"nosubscripts"
% option, which overrides the default option \verb"subscripts". This option
% makes partial derivatives such as
% \[ \begin{thermosubscripts}
% \Partial{\Vm}{P}{T} \qquad \text{(\texttt{subscripts} option)},
% \end{thermosubscripts}\relax \]
% and instead renders them
% \[ \begin{thermoNOsubscripts}
% \Partial{\Vm}{P}{T} \qquad \text{(\texttt{nosubscripts} option)},
% \end{thermoNOsubscripts} \]
% Combined with \verb"plain-derivatives", this would give
% \[ \begin{thermoplain}
% \Partial{\Vm}{P}{T} \qquad \text{(\texttt{nosubscripts} and
% \texttt{plain-derivatives} options)}.
% \end{thermoplain} \]
% The variables are sorted into an order defined by an internal constant,
% meaning $T$ will always be listed before $P$. The order by default is in
% the order that terms appear in the fundamental equations, that is,
% \begin{gather*}
% d\Ut = T \,d\St - P \,d\Vt + \mu \,d\Nt \\
% d\Ht = T \,d\St + \Vt \,dP + \mu \,d\Nt \\
% d\Ft = -\St\,dT - P \,d\Vt + \mu \,d\Nt \\
% \vdots \\
% d\Lt = -\St\,dT - P \,d\Vt - \Nt\,d\mu,
% \end{gather*}
% with the exception that subscripted variables are (currently) not sortable.
% If \verb"\Nt_i" or some similar construct appears as a variable and
% \verb"\allNsbut{i}" appears in the held-constant list, the package will
% assume that the argument list \emph{should} contain all of the mole numbers.
% Symbols without subscripts that are not in the fundamental equation or one of
% its variants are sorted in alphabetical order.
%
% \DescribeEnv{thermoparentheses}
% \DescribeEnv{thermobrackets}
% \DescribeEnv{thermobar}
% \DescribeEnv{thermoplain}
% If you want to use parentheses \emph{locally}, even though your overall
% document uses another delimiter, the \env{thermoparentheses} environment will
% do that. Similarly, \env{thermobrackets} will temporarily switch to brackets,
% \env{thermobar} will temporarily switch to a tailing vertical bar, and
% \env{thermoplain} will remove delimiters altogether.
%
% \DescribeEnv{thermosubscripts}
% \DescribeEnv{thermoNOsubscripts}
% The environments \env{thermosubscripts} and \env{thermoNOsubscripts}
% force the use or disuse of subscripts, respectively.
%
% \subsubsection{Options Regarding the Number of Moles}
% \DescribeMacro{\allNs}%
% \DescribeMacro{\allNsbut}%
% The default option \verb"moles-index" defines the macro \cs{allNs} to expand
% to $\allNs$ and the macro \verb"\allNsbut{i}" to expand to $\allNsbut{i}$.
% You can change the dummy index: \verb"\allNsbut[k]{i}" expands to
% $\allNsbut[k]{i}$ by default. This is typically not necessary, however: if
% you type \verb"\allNsbut{j}", the package will figure out that you want
% $\allNsbut{j}$ rather than $\Nt_{j\neq j}$. The time to use the optional
% argument is in situations such as
% \[ \Partial{\mu_j}{\Nt_k}{\allNsbut[i]{k}}, \]
% which is incorrect if the dummy index $j$ is used in place of the $i$.
%
% You can change these to expand to ranges using the \verb"moles-range"
% option, which renders \cs{allNs} as
% $\begin{thermomolesrange}\allNs\end{thermomolesrange}$ and
% \verb"\allNsbut{i}" as
% $\begin{thermomolesrange}\allNsbut{i}\end{thermomolesrange}.$
% The optional argument is ignored in this set of notation. Examples of these
% options are shown in Table~\ref{table:allNs}.
%
% \DescribeEnv{thermomolesrange}
% The environment \env{thermomolesrange} temporarily redefines \cs{allNs} and
% other range-oriented macros as though the |moles-range| package option had
% been invoked.
%
% \DescribeMacro{\ncomponents}%
% You can change the symbol for the number of components (default: $C$) by
% redefining the macro \cs{ncomponents}. This is done for you by some package
% options that define notation for particular textbooks.
%
% \begin{table}
% \caption{Illustration of the \texttt{moles-index} and \texttt{moles-range}
% options and their effects on \cs{allNs} and \cs{allNsbut}.}
% \label{table:allNs}
%^^A TODO The \leavevmode macro here is to prevent whitespace from building
%^^A up due to a bug in old versions of hypdoc. It should be harmless to
%^^A leave it in there, but consider removing it at some point.
% \leavevmode
% \SpecialMacroIndex{\allNs}\relax
% \SpecialMacroIndex{\allNsbut}\relax
% \SpecialMacroIndex{\allXs}\relax
% \SpecialMacroIndex{\allXsbut}\relax
% \centering
% \begin{minipage}{4.49in}\renewcommand*{\footnoterule}{\vskip-1.5ex}%
% \small
% \begin{tabular}{l l l}
% \toprule
% Macro\footnote{You may use $C$ directly instead of \cs{ncomponents}
% here, but then it will not change to another symbol if you want to
% switch to an option that redefines \cs{ncomponents} later.}
% & \verb"moles-index" & \verb"moles-range" \\
% \midrule
% \verb"\allNs" & $\allNs$
% & $\begin{thermomolesrange}\allNs\end{thermomolesrange}$ \\
% \verb"\allNsbut{1}" & $\allNsbut{1}$
% & $\begin{thermomolesrange}\allNsbut{1}\end{thermomolesrange}$ \\
% \verb"\allNsbut{i}" & $\allNsbut{i}$
% & $\begin{thermomolesrange}\allNsbut{i}\end{thermomolesrange}$ \\
% \verb"\allNsbut{j}" & $\allNsbut{j}$
% & $\begin{thermomolesrange}\allNsbut{j}\end{thermomolesrange}$ \\
% \verb"\allNsbut{\ncomponents}" & $\allNsbut{\ncomponents}$
% & $\begin{thermomolesrange}\allNsbut{\ncomponents}\end{thermomolesrange}$\\
% \verb"\allNsbut[k]{i}" & $\allNsbut[k]{i}$
% & $\begin{thermomolesrange}\allNsbut[k]{i}\end{thermomolesrange}$\\
% \verb"\allXs" & $\allXs$
% & $\begin{thermomolesrange}\allXs\end{thermomolesrange}$ \\
% \verb"\allXsbut{1}" & $\allXsbut{1}$
% & $\begin{thermomolesrange}\allXsbut{1}\end{thermomolesrange}$ \\
% \verb"\allXsbut{i}" & $\allXsbut{i}$
% & $\begin{thermomolesrange}\allXsbut{i}\end{thermomolesrange}$ \\
% \verb"\allXsbut{j}" & $\allXsbut{j}$
% & $\begin{thermomolesrange}\allXsbut{j}\end{thermomolesrange}$ \\
% \verb"\allXsbut{\ncomponents-1}" & $\allXsbut{\ncomponents-1}$
% & $\begin{thermomolesrange}\allXsbut{\ncomponents-1}
% \end{thermomolesrange}$ \\
% \verb"\allXsbut[k]{\ncomponents-1}" & $\allXsbut[k]{\ncomponents-1}$
% & $\begin{thermomolesrange}\allXsbut[k]{\ncomponents-1}
% \end{thermomolesrange}$ \\
% \verb"\allXsbut{\ncomponents}"\footnote{This would typically be used
% to denote something like
% \( \begin{thermomolesrange}
% \Gt(T,P,\Nt,\allXsbut{\ncomponents})
% \end{thermomolesrange}
% \) rather than in a subscript, but it looks silly if we do not
% handle this case this way.}
% & $\allXsbut{\ncomponents}$
% & $\begin{thermomolesrange}\allXsbut{\ncomponents}
% \end{thermomolesrange}$ \\
% \bottomrule
% \end{tabular}
% \end{minipage}
% \end{table}
%
% \subsubsection{Other Options}
% \DescribeMacro{\dbar}%
% The default for path-dependent one-forms (often called ``inexact
% differentials'') is \cs{dbar}, which looks like $\dbar$. This can be changed,
% if desired, to a delta ($\delta$) with the \verb"delta" option to the
% package.
%
% It should be noted that the \cs{dbar} macro is context-dependent: changing
% the typeface to something not supported will probably ruin it, as the kerning
% is very font-specific. This package currently supports Computer Modern,
% Times, Palatino, Bitstream Charter, Garamond, and Utopia, but other typefaces
% may require a manual redefinition.
%
% \subsubsection{Options for Particular Textbooks}
% There are several options that load package options and/or redefine
% particular commands to match the notation in a particular textbook. So far
% the following textbooks are supported:
% \begin{description}
% \item[Bejan] Notation used by Bejan, \emph{Advanced Engineering
% Thermodynamics}, Third Edition. Wiley: Hoboken, 2006. Loads non-default
% package options \verb"EUFGHAN", \verb"intensive-lowercase", and
% \verb"delta". Also swaps the notation for specific and
% intensive properties and redefines \cs{cV}, \cs{cVs}, \cs{cVt},
% \cs{expansivitysymbol}, and \cs{ncomponents} to match his notation.
% \item[CBK] Notation used by \c Cengel, Boles, and Kano\u glu,
% \emph{Thermodynamics: An Engineering Approach}, Ninth Edition.
% McGraw Hill: Singapore, 2020. Loads the non-default package options
% \verb"EUAGHAN" and \verb"intensive-lowercase"; also redefines
% partial molar, specific, and molar properties' notation to fit theirs,
% and redefines the internal symbol for pressure, \cs{Deltarxn},
% \cs{compressibilitysymbol}, and \cs{expansivitysymbol} to fit their
% usage. Their prodigal symbols for specific and total volume, which appear
% to be from the font ITC Benguiat Gothic Standard Book Oblique, are not
% supported.
% \item[ElliottLira] Notation used by Elliott and Lira, \emph{Introductory
% Chemical Engineering Thermodynamics}, Second Edition. Prentice Hall:
% Upper Saddle River, 2012. Loads the default package options and
% redefines \cs{IG}, \cs{IGM}, \cs{allcomponents}, and \cs{Deltarxn} to fit
% their notation.
% \item[Koretsky] Notation used by Koretsky, \emph{Engineering and Chemical
% Thermodynamics}, Second Edition, Wiley: New Caledonia, 2013.
% Loads the non-default package options \verb"EUAGHAn", \verb"brackets",
% \verb"intensive-lowercase", and \verb"delta"; modifies the
% \verb"intensive-lowercase" defaults to make uppercase partial molar
% properties to match Koretsky's notation and redefines
% \cs{expansivitysymbol}, \cs{IS}, \cs{residual}, \cs{IG}, \cs{IGM},
% \cs{Deltafus}, \cs{Deltasub}, \cs{Deltavap}, \cs{Henryrat},
% \cs{gammarat}, \cs{Deltafus}, \cs{Deltavap}, and \cs{Deltasub} to match
% his use. Also redefines the fugacity coefficients to use $\varphi$
% instead of $\phi$.
% \item[MSBB] Notation used by Moran, Shapiro, Boettner, and Bailey,
% \emph{Fundamentals of Engineering Thermodynamics}, Eighth Edition.
% Wiley: Kendallville, 2014. Loads the non-default package options
% \verb"EUFGHAn", \verb"intensive-lowercase", and \verb"delta"; removes the
% left parenthesis in partial derivatives and redefines \cs{IGM}, \cs{IG},
% \cs{expansitivitysymbol}, \cs{allcomponents}, \cs{allbut}, \cs{Ft},
% \cs{fmix}, and \cs{phimix}, as well as symbols for the Helmholtz free
% energy and pressure, intensive and specific property notation, and
% partial molar notation to fit their somewhat ill-advised notation.
% \item[Prausnitz] Notation used by Prausnitz, Lichtenthaler, and de Azevedo,
% \emph{Molecular Thermodynamics of Fluid-Phase Equilibria}, Third Edition,
% Pearson, 1998. Loads the non-default package option
% \verb"intensive-lowercase" and redefines \cs{fmix}, \cs{phimix},
% \cs{fpure}, \cs{phipure}, \cs{Henryrat}, \cs{residual},
% \cs{allcomponents}, and \cs{allbut} to fit their notation.
% \item[Sandler] Notation used by Sandler, \emph{Chemical, Biochemical, and
% Engineering Thermodynamics}, Fifth Edition. Wiley: Hoboken, 2017.
% Loads non-default package options \verb"EUAGHaN" and
% \verb"extensive-plain"; also redefines \cs{sat}, \cs{excess},
% \cs{residual}, \cs{ncomponents}, \cs{fmix}, \cs{fstd}, \cs{phimix},
% \cs{allcomponents}, \cs{IS}, \cs{Deltamix}, \cs{Deltarxn}, \cs{Deltasub},
% \cs{Deltafus}, \cs{Deltavap}, and \cs{Henryrat}. Also redefines \cs{cV},
% \cs{cP}, \cs{cVt}, and \cs{cPt}.
% \item[SVNAS] Notation used by Smith, Van Ness, Abbott, and Swihart,
% \emph{Introduction to Chemical Engineering Thermodynamics}, Ninth
% Edition. McGraw-Hill: Boston, 2021. Loads the non-default package option
% \verb"extensive-superscript" and redefines \cs{allcomponents},
% \cs{allbut}, \cs{IG}, \cs{IGM}, \cs{IS}, \cs{expansivitysymbol}, and
% \cs{Deltarxn} to fit their notation. The extensive heat capacities are
% also redefined, as they do not use such an entity.
% \item[TesterModell] Notation used by Tester and Modell,
% \emph{Thermodynamics and Its Applications}, Third Edition, Prentice Hall:
% Upper Saddle River, 1997. Loads the non-default package options
% \verb"EUAGHaN" and \verb"delta"; also redefines \cs{ncomponents} to be
% $n$ and redefines \cs{allcomponents}, \cs{allbut}, and \cs{allbutlastand}
% to fit their (somewhat inconsistent) notation. Also redefines \cs{IG},
% \cs{IGM}, \cs{IS}, \cs{excess}, \cs{reaction}, \cs{Henryrat},
% \cs{Henrymol}, \cs{gammarat}, and \cs{gammamol} to fit their style.
% \item[Thompson] Notation used by Thompson, \emph{A Unified Introduction to
% Chemical Engineering Thermodynamics}, Stillwater Press: Orono, 2000.
% Loads the non-default package options |EUAGHAn| and |delta|;
% also redefines \cs{excess}, \cs{residual}, \cs{Henryrat}, \cs{Henrymol},
% \cs{allcomponents}, \cs{ncomponents}, \cs{IS}, \cs{IG}, \cs{IGM},
% \cs{fpure}, \cs{phipure}, \cs{mix}, \cs{Deltamix}, \cs{Deltarxn}, and
% \cs{allbut} to match his notation, plus adjustments to intensive (molar)
% properties. Note that he uses $c$, $\mathrm{c}$, $n_C$, and
% $\mathrm{n}$ for the number of components in various places in the book;
% I chose $c$ for the definition of \cs{ncomponents}, but it is impossible
% to be completely consistent with his notation.
% \end{description}
% There may well be some inconsistencies between the notation in these books
% and the symbols used here. I will fix such inconsistencies as I become aware
% of them.
%^^X \end{documentation}
%
% \setcounter{IndexColumns}{2}
% \StopEventually{\PrintChanges\PrintIndex}
%
% ^^A--------------------------------------------------------------------------
% \iffalse
%<*package>
%<@@=thermodynamics>
% \fi
%
%^^X\begin{implementation}
% \section{Implementation}
% We set up some non-standard token comparison variants; these are designed
% to catch both \cs{ncomponents}=\cs{ncomponents} and \cs{ncomponents}=$C$
% (using the default options); we have to define \cs{ncomponents} to be
% expandable to make these work at all.
% \begin{macrocode}
\ExplSyntaxOn
\cs_generate_variant:Nn \tl_if_eq:nnTF { xxTF }
% \end{macrocode}
%
% This package requires the \pkg{amstext} package, as \tn{text} is used to
% handle \cs{sat}, \cs{IS}, \cs{IG}, \cs{IGM}, \cs{Henrymol}, \cs{fusion},
% \cs{reaction}, \cs{vaporization}, and \cs{sublimation} by default, as well
% as several other macros defined by package options.
% \begin{macrocode}
\RequirePackage{amstext}
% \end{macrocode}
%
% \subsection{Symbols Controlled by Package Options}
% We set some symbols prior to declaring the package options. The default
% symbols follow package option |EUAGHan|, even though the macros follow
% the option |EUFGHAN|.
%
% \begin{macro}{\dbar}
% The way \cs{dbar} is defined depends on the typeface you are using.
% We try to determine, at \verb"\begin{document}", which typeface you chose
% based on the packages that are loaded and some of their internal definitions.
% The \textsf{thermodynamics} package currently supports
% Computer Modern (the default or through \pkg{lmodern}),
% Palatino (through \pkg{pxfonts} or \pkg{newpxmath}),
% Times (through \pkg{txfonts}, \pkg{mathptmx}, or \pkg{newtxmath}),
% Utopia (through \pkg{mathdesign}),
% Bitstream Charter (through \pkg{mathdesign}), and
% Garamond (through \pkg{mathdesign}).
% Definitions of \cs{dbar} (with \cs{newcommand*}, \cs{providecommand*},
% \cs{NewDocumentCommand}, or \cs{ProvideDocumentCommand})
% in the preamble will override the ones here.
% \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{pxfonts}{%
\ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-10mu d}
}{}
\@ifpackageloaded{newpxmath}{%
\ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-10mu d}
}{}
\@ifpackageloaded{txfonts}{%
\ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-11mu d}
}{}
\@ifpackageloaded{mathptmx}{%
\ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-10mu d}
}{}
\@ifpackageloaded{newtxmath}{%
\ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-11mu d}
}{}
\@ifpackageloaded{mathdesign}{%
\tl_const:Nn \c_@@_charter_tl {mdbch}
\tl_const:Nn \c_@@_utopia_tl {mdput}
\tl_const:Nn \c_@@_garamond_tl {mdugm}
\tl_if_eq:NNT \MD@default@family \c_@@_utopia_tl
{ \ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-20mu d}
}
\tl_if_eq:NNT \MD@default@family \c_@@_charter_tl
{ \ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-15mu d}
}
\tl_if_eq:NNT \MD@default@family \c_@@_garamond_tl
{ \ProvideDocumentCommand{\dbar}{}
{\mkern5mu\mathchar'26\mkern-17mu d}
}
}{}
% Defaults to Computer Modern
\ProvideDocumentCommand{\dbar}{}
{\mkern3mu\mathchar'26\mkern-12mu d}
}
% \end{macrocode}
% \end{macro}
%
% Symbols are defined for the total energy, internal energy, Helmholtz free
% energy, Gibbs free energy, enthalpy, entropy, surface area, volume, number
% of moles, heat, and work; these are $E$, $U$, $A$, $G$, $H$, $S$, $a$,
% $V$, $n$, $Q$, and $W$, respectively. These commands should not be used on
% their own, but rather accessed through the macros \cs{Ut}, \cs{Um}, and
% \cs{Us} (using the internal energy as an example).
%
% The default symbols are not intended to be easy to change---the intended
% mechanism is through package options. If you want to use a non-standard
% symbol that is not available through one of the package options, you can
% redefine the internal token lists inside
% \cs{ExplSyntaxOn}\dots\cs{ExplSyntaxOff}. For example,
% \begin{verbatim}
% \ExplSyntaxOn
% \tl_gset:Nn \g__thermodynamics_Helmholtz_symbol {H}
% \tl_gset:Nn \g__thermodynamics_enthalpy_symbol {h}
% \ExplSyntaxOff
%\end{verbatim}
% would define the ill-advised notation that I have nonetheless heard of
% that uses $H$ for Helmholtz free energy and $h$ for enthalpy.
% Note that the macros for temperature and pressure are only used inside
% the definitions of the compressibilities, expansivitites, and heat
% capacities; there is no user-level macro for the temperature or the pressure,
% so it is up to the user to use consistent symbols for those properties.
% \begin{macrocode}
\tl_new:N \g_@@_total_energy_symbol
\tl_new:N \g_@@_internal_energy_symbol
\tl_new:N \g_@@_Helmholtz_symbol
\tl_new:N \g_@@_Gibbs_symbol
\tl_new:N \g_@@_Landau_symbol
\tl_new:N \g_@@_enthalpy_symbol
\tl_new:N \g_@@_entropy_symbol
\tl_new:N \g_@@_area_symbol
\tl_new:N \g_@@_volume_symbol
\tl_new:N \g_@@_mole_symbol
\tl_new:N \g_@@_heat_symbol
\tl_new:N \g_@@_work_symbol
\tl_new:N \g_@@_temperature_symbol
\tl_new:N \g_@@_pressure_symbol
\tl_gset:Nn \g_@@_total_energy_symbol E
\tl_gset:Nn \g_@@_internal_energy_symbol U
\tl_gset:Nn \g_@@_Helmholtz_symbol A
\tl_gset:Nn \g_@@_Gibbs_symbol G
\tl_gset:Nn \g_@@_Landau_symbol \Omega
\tl_gset:Nn \g_@@_enthalpy_symbol H
\tl_gset:Nn \g_@@_entropy_symbol S
\tl_gset:Nn \g_@@_area_symbol a
\tl_gset:Nn \g_@@_volume_symbol V
\tl_gset:Nn \g_@@_mole_symbol n
\tl_gset:Nn \g_@@_heat_symbol Q
\tl_gset:Nn \g_@@_work_symbol W
\tl_gset:Nn \g_@@_temperature_symbol T
\tl_gset:Nn \g_@@_pressure_symbol P
% \end{macrocode}
%
% We then define two functions and several lengths that we shall use when
% drawing rules above or below a symbol. The default is to use underlined
% symbols for extensive quantities, plain symbols for molar quantities, and
% carets for specific quantities, but this can be changed using package
% options.
%^^A TODO these might work better as kern 0.1*width, symbol, kern 0.2*width
% \begin{macrocode}
\cs_new:Nn \@@_underline:n
{ \mkern1mu\underline{\mkern-1mu #1\mkern-4mu}\mkern4mu }
\cs_new:Nn \@@_overline:n
{ \mkern2mu\overline{\mkern-2mu #1\mkern-1mu}\mkern1mu }
% \end{macrocode}
%
% \begin{macro}{\PartialOpen,\PartialClose,\PartialEmptyClose}
% We define three commands to use to denote the beginning and end of partial
% derivatives. These symbols can be customized by package options. Default
% is |parentheses|, meaning that \verb"\[ \Partial{f}{x}{y} \]" renders as
% \[ \left(\frac{\partial f}{\partial x}\right)_y \]
% with the defaults. The macro \cs{PartialEmptyClose} is used when the last
% argument to \cs{Partial} is empty, which is important for the |bar|
% option to the document class or inside the \env{thermobar} environment.
% \begin{macrocode}
\tl_new:N \l_@@_PartialOpen_tl
\tl_new:N \l_@@_PartialEmptyClose_tl
\tl_new:N \l_@@_PartialClose_tl
\tl_set:Nn \l_@@_PartialOpen_tl {(}
\tl_set:Nn \l_@@_PartialClose_tl {)}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {)}
% \end{macrocode}
% \end{macro}
%
% \subsection{Package Options}
% We declare a bunch of options for which sets of symbols to use.
% These are summarized in Table~\ref{table:symbol-sets}.
% \changes{v1.01}{2023/09/15}{Changed options with two $E$ or two $A$
% variables to use calligraphic letters for the less-common of the two.}
% \begin{macrocode}
\DeclareOption{EUAGHan}{}% the default
\DeclareOption{EUAGHaN}{\tl_gset:Nn \g_@@_mole_symbol N}%
\DeclareOption{EUHAGan}{\ExecuteOptions{EUAGHan}}
\DeclareOption{EUHAGaN}{\ExecuteOptions{EUAGHaN}}
\DeclareOption{EUFGHAn}{%
\tl_gset:Nn \g_@@_Helmholtz_symbol F
\tl_gset:Nn \g_@@_area_symbol A
}
\DeclareOption{EUFGHAN}{%
\tl_gset:Nn \g_@@_Helmholtz_symbol F
\tl_gset:Nn \g_@@_area_symbol A
\tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EEFGHAn}{%
\tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
\tl_gset:Nn \g_@@_internal_energy_symbol E
\tl_gset:Nn \g_@@_Helmholtz_symbol F
\tl_gset:Nn \g_@@_area_symbol A
}
\DeclareOption{EEFGHAN}{%
\tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
\tl_gset:Nn \g_@@_internal_energy_symbol E
\tl_gset:Nn \g_@@_Helmholtz_symbol F
\tl_gset:Nn \g_@@_area_symbol A
\tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EEFGHan}{%
\tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
\tl_gset:Nn \g_@@_internal_energy_symbol E
\tl_gset:Nn \g_@@_Helmholtz_symbol F
}
\DeclareOption{EEFGHaN}{%
\tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
\tl_gset:Nn \g_@@_internal_energy_symbol E
\tl_gset:Nn \g_@@_Helmholtz_symbol F
\tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EEAGHan}{%
\tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
\tl_gset:Nn \g_@@_internal_energy_symbol E
}
\DeclareOption{EEAGHaN}{%
\tl_gset:Nn \g_@@_total_energy_symbol {\mathcal{E}}
\tl_gset:Nn \g_@@_internal_energy_symbol E
\tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EUAGHAn}{%
\tl_gset:Nn \g_@@_area_symbol {\mathcal{A}}
}
\DeclareOption{EUAGHAN}{%
\tl_gset:Nn \g_@@_area_symbol {\mathcal{A}}
\tl_gset:Nn \g_@@_mole_symbol N
}
\DeclareOption{EUFGHan}{%
\tl_gset:Nn \g_@@_Helmholtz_symbol F
}
\DeclareOption{EUFGHaN}{%
\tl_gset:Nn \g_@@_Helmholtz_symbol F
\tl_gset:Nn \g_@@_mole_symbol N
}
% \end{macrocode}
% The |delta| option redefines \cs{dbar} to produce the symbol $\delta$.
% The default is to use a $d$ with a slash through it ($\dbar$) for inexact
% differentials unless the user overrides it with this option. The macro could
% also be redefined manually, of course.
% \begin{macrocode}
\DeclareOption{delta}{ \cs_set_eq:NN \dbar \delta }
% \end{macrocode}
%
% Next, we define options for the set of notation. The default is
% |intensive-plain|, which produces things like $V$ for molar volume,
% $\Vt$ for total volume, and $\hat V$ for specific volume.
% The symbols themselves are produced via internal (non-user-facing) macros.
% \begin{macrocode}
\cs_new:Nn \@@_extensive:n {#1}
\cs_new:Nn \@@_intensive:n {#1}
\cs_new:Nn \@@_specific:n {\hat{#1}}
\cs_new:Npn \@@_set_intensive_plain
{
\cs_set:Nn \@@_extensive:n {\@@_underline:n{##1}}
\cs_set:Nn \@@_intensive:n {##1}
}
\cs_new:Npn \@@_set_extensive_plain
{
\cs_set:Nn \@@_extensive:n {##1}
\cs_set:Nn \@@_intensive:n {\@@_underline:n{##1}}
}
\cs_new:Npn \@@_set_lowercase_pms
{
\RenewDocumentCommand{\partialmolar}{m}
{
\tl_set:Nn \l_@@_pm_symbol_tl {\text_lowercase:n {##1}}
\@@_generic_pm:
}
}
\cs_new:Npn \@@_set_intensive_lowercase
{
\cs_set:Nn \@@_extensive:n {\text_uppercase:n {##1}}
\cs_set:Nn \@@_intensive:n {\text_lowercase:n {##1}}
\cs_set:Nn \@@_specific:n {\hat{\text_lowercase:n {##1}}}
}
\cs_new:Npn \@@_set_extensive_superscripts
{
\cs_set:Nn \@@_extensive:n {{##1}\c_math_superscript_token t}
\cs_set:Nn \@@_intensive:n {##1}
}
\DeclareOption{extensive-plain}{\@@_set_extensive_plain}
\DeclareOption{intensive-plain}{\@@_set_intensive_plain} % the default
\DeclareOption{intensive-lowercase}{% PLEASE don't use this!
\@@_set_intensive_lowercase
\AtEndOfPackage{
\@@_set_lowercase_pms
\RenewDocumentCommand{\heatcapacitysymbol}{}{c}
}
}
\DeclareOption{extensive-superscript}{%
\@@_set_extensive_superscripts
\AtEndOfPackage{%
\RenewDocumentCommand{\URt}{}{\g_@@_internal_energy_symbol
\c_math_superscript_token{\residual,t}}
\RenewDocumentCommand{\HRt}{}{\g_@@_enthalpy_symbol
\c_math_superscript_token{\residual,t}}
\RenewDocumentCommand{\FRt}{}{\g_@@_Helmoholtz_symbol
\c_math_superscript_token{\residual,t}}
\RenewDocumentCommand{\GRt}{}{\g_@@_Gibbs_symbol
\c_math_superscript_token{\residual,t}}
\RenewDocumentCommand{\VRt}{}{\g_@@_volume_symbol
\c_math_superscript_token{\residual,t}}
\RenewDocumentCommand{\SRt}{}{\g_@@_entropy_symbol
\c_math_superscript_token{\residual,t}}
\RenewDocumentCommand{\UEt}{}{\g_@@_internal_energy_symbol
\c_math_superscript_token{\excess,t}}
\RenewDocumentCommand{\HEt}{}{\g_@@_enthalpy_symbol
\c_math_superscript_token{\excess,t}}
\RenewDocumentCommand{\FEt}{}{\g_@@_Helmoholtz_symbol
\c_math_superscript_token{\excess,t}}
\RenewDocumentCommand{\GEt}{}{\g_@@_Gibbs_symbol
\c_math_superscript_token{\excess,t}}
\RenewDocumentCommand{\VEt}{}{\g_@@_volume_symbol
\c_math_superscript_token{\excess,t}}
\RenewDocumentCommand{\SEt}{}{\g_@@_entropy_symbol
\c_math_superscript_token{\excess,t}}
}
}
% \end{macrocode}
%
% The next two options choose whether variables held constant are subscripted
% (the default) or placed next to the function. The difference is
%%^^A \[ \left(\frac{\partial U}{\partial S}\right)_V \quad\text{versus}\quad
%%^^A \left(\frac{\partial U(S,V)}{\partial S}\right) \]
% \[ \Partial{\Um}{\Sm}{\Vm} \quad\text{versus}\quad
% \begin{thermoNOsubscripts}
% \Partial{\Um}{\Sm}{\Vm}
% \end{thermoNOsubscripts} \]
% for \verb"subscripts" and \verb"nosubscripts", respectively.
% \begin{macrocode}
\bool_new:N \l_@@_subscripted_bool
\bool_set_true:N \l_@@_subscripted_bool
\DeclareOption{subscripts}{\bool_set_true:N \l_@@_subscripted_bool}
\DeclareOption{nosubscripts}{\bool_set_false:N \l_@@_subscripted_bool}
% \end{macrocode}
% These options change how \cs{Partial} and friends render derivatives.
% The default is parentheses, but other options include brackets, braces,
% a vertical bar on the right side, or plain (undecorated) derivatives.
% \begin{macrocode}
\DeclareOption{parentheses}{}
\DeclareOption{brackets}{%
\tl_set:Nn \l_@@_PartialOpen_tl {[}
\tl_set:Nn \l_@@_PartialClose_tl {]}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {]}
}
\DeclareOption{braces}{%
\tl_set:Nn \l_@@_PartialOpen_t1 {\{}
\tl_set:Nn \l_@@_PartialClose_t1 {\}}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {\}}
}
\DeclareOption{bar}{%
\tl_set:Nn \l_@@_PartialOpen_tl {.}
\tl_set:Nn \l_@@_PartialClose_tl {\rvert}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
}
\DeclareOption{plain-derivatives}{% This implies dU(S,V,N)/dS notation
\tl_set:Nn \l_@@_PartialOpen_tl {.}
\tl_set:Nn \l_@@_PartialClose_tl {.}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
\ExecuteOptions{nosubscripts}
}
% \end{macrocode}
% \subsection{The Number of Moles Macros}
% \begin{macro}{\ncomponents}
% We define the number of components, default $C$, for use in the ``all moles''
% and related macros. The command is expandable so we can perform comparisons
% to user-entered values.
% \begin{macrocode}
\NewExpandableDocumentCommand \ncomponents {} {C}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\allNs,\allXs,\allYs,\allmus,\allMs,\allWs}
% Several macros define a shorthand for ``moles of all species'' (\cs{allNs})
% and ``moles of all species except'' (\cs{allNsbut}), as well as similar
% quantities for masses (\cs{allMs}, \cs{allMsbut}) and chemical potentials
% (\cs{allmus}, \cs{allmusbut}), which occur frequently in mixture
% thermodynamics. The default is for \cs{allNs} to become $\vec{n}$ and
% \verb"allNsbut{i}" to become $n_{j\neq i}$. The optional argument changes
% which index (default: $j$) to use in the left side of the inequality.\relax
% \footnote{The index \!$j$ is automatically replaced with $k$ if the user
% issues \texttt{\textbackslash allNsbut\{j\}}.}
% Essentially identical commands are defined for chemical potentials and
% masses: \cs{allmus} and \cs{allmusbut} and \cs{allMs} and \cs{allMsbut},
% respectively.
% \begin{macrocode}
\NewDocumentCommand{\allNs}{O{i}}{\allcomponents[#1]{\Nt}}
\NewDocumentCommand{\allXs}{O{i}}{\allcomponents[#1]{x}}
\NewDocumentCommand{\allYs}{O{i}}{\allcomponents[#1]{y}}
\NewDocumentCommand{\allmus}{O{i}}{\allcomponents[#1]{\mu}}
\NewDocumentCommand{\allMs}{O{i}}{\allcomponents[#1]{m}}
\NewDocumentCommand{\allWs}{O{i}}{\allcomponents[#1]{w}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\allNsbut,\allXsbut,\allYsbut,\allMsbut,\allWsbut}
% Similar commands are defined for mole fractions (\cs{allXs}, \cs{allYs},
% etc.), but these assume the last mole fraction is \emph{not} one of the
% variables---that is, \cs{allXsbut} and \cs{allYsbut} assume the argument
% \emph{and} \cs{ncomponents} are held constant. For example,
% \begin{verbatim}
% \[ \Partial{\Gm}{T}{P,\allXs} = -\Sm \qquad
% \Partial{\Gm}{x_i}{T,P,\allXsbut{i}} \neq \Gpm_i \]
%\end{verbatim}
% yields
% \[ \Partial{G}{T}{P,\allXs} = -S \qquad
% \Partial{G}{x_i}{T,P,x_{j\neq i,C}} \neq \Gpm{i}. \]
% \begin{macrocode}
\NewDocumentCommand{\allNsbut}{O{j} m} {\allbut[#1]{#2}{\Nt}}
\NewDocumentCommand{\allXsbut}{O{j} m} {\allbutlastand[#1]{#2}{x}}
\NewDocumentCommand{\allYsbut}{O{j} m} {\allbutlastand[#1]{#2}{y}}
\NewDocumentCommand{\allmusbut}{O{j} m} {\allbut[#1]{#2}{\mu}}
\NewDocumentCommand{\allMsbut}{O{j} m} {\allbut[#1]{#2}{m}}
\NewDocumentCommand{\allWsbut}{O{j} m} {\allbutlastand[#1]{#2}{w}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\allbutlastand,\allbut,\allcomponents}
% \changes{v1.01}{10/04/2023}{Updated \cs{allcomponents} to include an
% optional argument that changes $N_i$ to $N_j$, say, when using
% TesterModell or other options that denote moles of all components that
% way. Similar updates to \cs{allNs} and friends.}
% The \cs{allcomponents}, \cs{allbut}, and \cs{allbutlastand} macros can be
% used to define new entities; say, if you want to use $z_i$ as a mole
% fraction, then use
% \begin{verbatim}
% \NewDocumentCommand{\allZsbut}{O{j} m}{\allbutlastand[#1]{#2}{z}}
%\end{verbatim}
% Similarly, something meaning the concentrations of every species could be
% defined via
% \begin{verbatim}
% \NewDocumentCommand{\allCs}{O{}}{\allcomponents{C}}
%\end{verbatim}
% \begin{macrocode}
\NewDocumentCommand{\allcomponents}{O{} m}{\vec{#2}}
\NewDocumentCommand{\allbut}{O{j} m m}
{ \tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token{k \neq #2} }
{ {#3}\c_math_subscript_token{#1 \neq #2} }
}
\NewDocumentCommand{\allbutlastand}{O{j} m m}
{ \tl_if_eq:xxTF {#2} {\ncomponents}
{ {#3}\c_math_subscript_token{#1 \neq #2} }
{ \tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token{k \neq #2,\ncomponents} }
{ {#3}\c_math_subscript_token{#1 \neq #2,\ncomponents} }
}
}
% \end{macrocode}
% \end{macro}
%
% We then define two package options that change how to render \cs{allNs} and
% friends.\relax
% \changes{v1.01}{2022/05/04}{Fixed bug in \cs{allbutlastand} when using the
% |moles-range| option ($C$ should have been $C-1$ in the last option).}
% \begin{macrocode}
\DeclareOption{moles-index}{}
\DeclareOption{moles-range}{ \@@_set_moles_range }
\cs_new:Npn \@@_set_moles_range {%
\RenewDocumentCommand{\allcomponents}{O{} m}
{ {##2}\c_math_subscript_token 1,\dots,
{##2}\c_math_subscript_token{\ncomponents} }
\RenewDocumentCommand{\allbut}{O{j} m m}
{ \tl_if_eq:nnTF {##2} {1}
{ {##3}\c_math_subscript_token 2,\dots,
{##3}\c_math_subscript_token{\ncomponents} }
{ \tl_if_eq:xxTF {##2} {\ncomponents}
{ {##3}\c_math_subscript_token 1,\dots,
{##3}\c_math_subscript_token{\ncomponents-1} }
{ {##3}\c_math_subscript_token 1,\dots,
[{##3}\c_math_subscript_token{##2}],
\dots,{##3}\c_math_subscript_token{\ncomponents} }
}
}
\RenewDocumentCommand{\allbutlastand}{O{j} m m}
{ \tl_if_eq:nnTF {##2} {1}
{ {##3}\c_math_subscript_token 2,\dots,
{##3}\c_math_subscript_token{\ncomponents-1} }
{ \tl_if_eq:xxTF {##2} {\ncomponents}
{ {##3}\c_math_subscript_token 1,\dots,
{##3}\c_math_subscript_token{\ncomponents-1}
}
{ \tl_if_eq:xxTF {##2} {\ncomponents-1}
{ {##3}\c_math_subscript_token 1,\dots,
{##3}\c_math_subscript_token{\ncomponents-2} }
{
{##3}\c_math_subscript_token 1,\dots,
[{##3}\c_math_subscript_token{##2}],\dots,
{##3}\c_math_subscript_token{\ncomponents-1}
}
}
}
}
}
% \end{macrocode}
% The remaining options define textbook-specific notation.
% \begin{macrocode}
\DeclareOption{Bejan}{
\ExecuteOptions{EUFGHAN,intensive-lowercase,delta}
\cs_set:Nn \@@_specific:n {\text_lowercase:n {#1}}
\cs_set:Nn \@@_intensive:n {\bar{\text_lowercase:n {#1}}}
\tl_gset:Nn \g_@@_volume_symbol v
}
\DeclareOption{CBK}{
\ExecuteOptions{EUAGHAN,intensive-lowercase}
\AtEndOfPackage{
\cs_set:Nn \@@_overline:n {\widetilde{#1}}
\cs_set:Nn \@@_specific:n {\text_lowercase:n {#1}}
\cs_set:Nn \@@_intensive:n {\bar{\text_lowercase:n{#1}}}
\tl_gset:Nn \g_@@_pressure_symbol p
\RenewDocumentCommand{\Deltarxn}{m}{{#1}\c_math_subscript_token R}
\RenewDocumentCommand{\compressibilitysymbol}{}{\beta}
\RenewDocumentCommand{\expansivitysymbol}{}{\alpha}
}
}
\DeclareOption{ElliottLira}{
\AtEndOfPackage{
\RenewDocumentCommand{\allcomponents}{O{} m}{#2}
\RenewDocumentCommand{\Deltarxn}{m}{\Delta #1}
\RenewDocumentCommand{\IG}{}{{\text{ig}}}
\RenewDocumentCommand{\IGM}{}{{\text{ig}}}
\RenewDocumentCommand{\IS}{}{{\text{is}}}
}
}
\DeclareOption{Koretsky}{
\ExecuteOptions{EUAGHAn,brackets,intensive-lowercase,delta}
\AtEndOfPackage{
%^^A Undo part of intensive-lowercase
\RenewDocumentCommand{\partialmolar}{m}
{ \tl_set:Nn \l_@@_pm_symbol_tl {#1}
\@@_generic_pm:
}
\RenewDocumentCommand{\expansivitysymbol}{}{\beta}
\RenewDocumentCommand{\IS}{}{{\text{ideal}}}
\RenewDocumentCommand{\residual}{}{{\text{dep}}}
\RenewDocumentCommand{\IG}{}{{\text{ideal}}}
\RenewDocumentCommand{\IGM}{}{{\text{ideal}}}
\RenewDocumentCommand{\Henryrat}{}{{\mathcal{H}}}
\RenewDocumentCommand{\gammarat}{}
{\gamma\c_math_superscript_token\text{Henry's}}
\RenewDocumentCommand{\phipure}{}{\varphi}
\RenewDocumentCommand{\phimix}{}{\hat\varphi}
\RenewDocumentCommand{\phisat}{}{\varphi\c_math_superscript_token\sat}
\cs_new:Npn \Delta_fus_sym {} {}
\NewSubscriptedSymbol{\Delta_fus}{\Delta_fus_sym}{\fusion}
\RenewDocumentCommand{\Deltafus}{m}{
\cs_set:Npn \Delta_fus_sym {} { \Delta #1 }
\Delta_fus
}
\cs_new:Npn \Delta_vap_sym {} {}
\NewSubscriptedSymbol{\Delta_vap}{\Delta_vap_sym}{\vaporization}
\RenewDocumentCommand{\Deltavap}{m}{
\cs_set:Npn \Delta_vap_sym {} { \Delta #1 }
\Delta_vap
}
\cs_new:Npn \Delta_sub_sym {} {}
\NewSubscriptedSymbol{\Delta_sub}{\Delta_sub_sym}{\sublimation}
%^^A Undo part of intensive-lowercase
\RenewDocumentCommand{\Deltasub}{m}{
\cs_set:Npn \Delta_sub_sym {} { \Delta #1 }
\Delta_sub
}
}
}
\DeclareOption{MSBB}{
\ExecuteOptions{EUFGHAn,intensive-lowercase,delta}
\AtEndOfPackage{
\RenewDocumentCommand{\IGM}{}{\ast}
\RenewDocumentCommand{\IG}{}{\ast}
\RenewDocumentCommand{\expansivitysymbol}{}{\beta}
\RenewDocumentCommand{\allcomponents}{O{} m}{#2}
\RenewDocumentCommand{\allbut}{O{j} m m}
{
\tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token k }
{ {#3}\c_math_subscript_token{#1} }
}
\tl_gset_eq:NN \g_@@_Helmholtz_symbol \psi
\RenewDocumentCommand{\Ft}{}{\Psi}
\cs_set:Nn \@@_intensive:n {\@@_overline:n{\text_lowercase:n{#1}}}
\cs_set:Nn \@@_specific:n {\text_lowercase:n{#1}}
\RenewDocumentCommand{\fmix}{}{\bar f}
\RenewDocumentCommand{\phimix}{}{\bar\phi}
\RenewDocumentCommand{\phimix}{}{\bar\phi}
\tl_gset:Nn \g_@@_pressure_symbol p
\RenewDocumentCommand{\partialmolar}{m}
{
\tl_set:Nn \l_@@_pm_symbol_tl {#1}
\@@_generic_pm:
}
}
}
\DeclareOption{Prausnitz}{
\ExecuteOptions{intensive-lowercase}
\AtEndOfPackage{
\RenewDocumentCommand{\fmix}{}{f}
\RenewDocumentCommand{\phimix}{}{\phi}
\RenewDocumentCommand{\fsat}{}{\fpure\c_math_superscript_token\sat}
% TODO: this should pick up H_2 and make it into H_{2,1} (assuming the
% solvent is always 1...?)
\RenewDocumentCommand{\Henryrat}{}{H}
\RenewDocumentCommand{\residual}{}{{{\mathcal{R}}}}
\RenewDocumentCommand{\allcomponents}{O{i} m}
{ {#2}\c_math_subscript_token{#1} }
\RenewDocumentCommand{\allbut}{O{i} m m}
{ \tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token k }
{ {#3}\c_math_subscript_token{#1} }
}
\RenewSubscriptedSymbol{\fpure}{f}{{\text{pure}}}
\RenewSubscriptedSymbol{\phipure}{\phi}{{\text{pure}}}
}
}
\DeclareOption{Sandler}{
\ExecuteOptions{EUAGHaN,extensive-plain}
\AtEndOfPackage{
\RenewDocumentCommand{\sat}{}{{\text{vap}}}
\RenewDocumentCommand{\excess}{}{{\text{ex}}}
\RenewDocumentCommand{\residual}{}{{\text{r}}}
\RenewExpandableDocumentCommand{\ncomponents}{}{\mathcal{C}}
\RenewDocumentCommand{\fmix}{}{\bar f}
\RenewDocumentCommand{\fstd}{}{\bar f\c_math_superscript_token\std}
\RenewDocumentCommand{\phimix}{}{\bar\phi}
\RenewDocumentCommand{\allcomponents}{O{} m}{\@@_underline:n{#2}}
\RenewDocumentCommand{\IG}{}{{\text{IG}}}
\RenewDocumentCommand{\IGM}{}{{\text{IGM}}}
\RenewDocumentCommand{\IS}{}{{\text{IM}}}
\RenewDocumentCommand{\Deltamix}{m}
{\Delta\c_math_subscript_token\mixing #1}
\RenewDocumentCommand{\Deltarxn}{m}
{\Delta\c_math_subscript_token\reaction #1}
\RenewDocumentCommand{\Deltasub}{m}
{\Delta\c_math_subscript_token\sublimation #1}
\RenewDocumentCommand{\Deltafus}{m}
{\Delta\c_math_subscript_token\fusion #1}
\RenewDocumentCommand{\Deltavap}{m}
{\Delta\c_math_subscript_token\vaporization #1}
\RenewDocumentCommand{\Henryrat}{}{H}
\RenewSubscriptedSymbol{\cV}
{\heatcapacitysymbol}{\g_@@_volume_symbol}
\RenewSubscriptedSymbol{\cP}
{\heatcapacitysymbol}{\g_@@_pressure_symbol}
\RenewSubscriptedSymbol{\cVt}
{\Nt\heatcapacitysymbol}{\g_@@_volume_symbol}
\RenewSubscriptedSymbol{\cPt}
{\Nt\heatcapacitysymbol}{\g_@@_pressure_symbol}
}
}
\DeclareOption{SVNAS}{
\ExecuteOptions{extensive-superscript}
\AtEndOfPackage{
\RenewDocumentCommand{\allcomponents}{O{} m}{#2}
\RenewDocumentCommand{\allbut}{O{j} m m}
{
\tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token k }
{ {#3}\c_math_subscript_token{#1} }
}
\RenewDocumentCommand{\IG}{}{{ig}}
\RenewDocumentCommand{\IGM}{}{{ig}}
\RenewDocumentCommand{\IS}{}{{id}}
\RenewDocumentCommand{\expansivitysymbol}{}{\beta}
\RenewDocumentCommand{\Deltarxn}{m}{\Delta #1}
\RenewSubscriptedSymbol{\cVt}
{\Nt\heatcapacitysymbol}{\g_@@_volume_symbol}
\RenewSubscriptedSymbol{\cPt}
{\Nt\heatcapacitysymbol}{\g_@@_pressure_symbol}
}
}
\DeclareOption{TesterModell}{
\ExecuteOptions{EUAGHaN,delta}
\AtEndOfPackage{
\RenewExpandableDocumentCommand{\ncomponents}{}{n}
\RenewDocumentCommand{\allcomponents}{O{i} m}
{
{#2}\c_math_subscript_token{#1}
}
\RenewDocumentCommand{\allbut}{O{i} m m}
{ \tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token{k}[#2] }
{ {#3}\c_math_subscript_token{#1}[#2] }
}
\RenewDocumentCommand{\allbutlastand}{O{j} m m}
{ \tl_if_eq:xxTF {#2} {\ncomponents}
{ {#3}\c_math_subscript_token{#1}\relax[#2] }
{ \tl_if_eq:nnTF {#1} {#2}
{ {#3}\c_math_subscript_token{k}[#2,\ncomponents] }
{ {#3}\c_math_subscript_token{#1}[#2,\ncomponents] }
}
}
\RenewDocumentCommand{\IG}{}{{o}}
\RenewDocumentCommand{\IGM}{}{{o}}
\RenewDocumentCommand{\IS}{}{{ID}}
\RenewDocumentCommand{\excess}{}{{EX}}
\RenewDocumentCommand{\reaction}{}{{rx}}
\RenewDocumentCommand{\Henryrat}{}
{f\c_math_superscript_token{\ast\ast}}
\RenewDocumentCommand{\Henrymol}{}{f\c_math_superscript_token\ast}
\RenewDocumentCommand{\gammarat}{}
{\gamma\c_math_superscript_token{\ast\ast}}
\RenewDocumentCommand{\gammamol}{}
{\gamma\c_math_superscript_token\ast}
\RenewExpandableDocumentCommand{\JTsymbol}{}{\alpha}
\RenewSubscriptedSymbol{\muJT}{\JTsymbol}{H}
}
}
\DeclareOption{Thompson}{
\ExecuteOptions{EUAGHAn,delta}
\AtEndOfPackage
{
\RenewDocumentCommand{\excess}{}{{EX}}
\RenewDocumentCommand{\residual}{}{{R}}
%^^A He uses k_H for both types of Henry's constant, but I changed
%^^A the rational basis one just so there is SOME difference
\RenewSubscriptedSymbol{\Henryrat}{k}{h}
\RenewSubscriptedSymbol{\Henrymol}{k}{H}
\RenewDocumentCommand{\allcomponents}{O{j} m}
{
{#2}\c_math_subscript_token{#1}
}
\RenewDocumentCommand{\allNs}{O{j}}{\allcomponents[#1]{\Nt}}
\RenewDocumentCommand{\allXs}{O{j}}{\allcomponents[#1]{x}}
\RenewDocumentCommand{\allYs}{O{j}}{\allcomponents[#1]{y}}
\RenewDocumentCommand{\allmus}{O{j}}{\allcomponents[#1]{\mu}}
\RenewDocumentCommand{\allMs}{O{j}}{\allcomponents[#1]{m}}
\RenewDocumentCommand{\allWs}{O{j}}{\allcomponents[#1]{w}}
\RenewExpandableDocumentCommand{\ncomponents}{}{c}
\RenewDocumentCommand{\IS}{}{{IS}}
\RenewDocumentCommand{\IG}{}{{IG}}
\RenewDocumentCommand{\IGM}{}{{IG}}
\cs_new:Nn \@@_fpure_one:n
{
f\c_math_subscript_token{#1}
\peek_catcode_remove:NF \c_math_superscript_token
{ \c_math_superscript_token\bullet }
}
\RenewDocumentCommand{\fpure}{}
{
\peek_catcode_remove:NTF \c_math_subscript_token
{ \@@_fpure_one:n }
{ f }
}
\cs_new:Nn \@@_intensive_two:n
{
\c_math_subscript_token{#1}
\peek_catcode:NF \c_math_superscript_token
{
\c_math_superscript_token\bullet
}
}
\cs_set:Nn \@@_intensive:n
{ #1
\peek_catcode_remove:NT \c_math_subscript_token
{ \@@_intensive_two:n }
}
\cs_new:Nn \@@_phipure_one:n
{
\phi\c_math_subscript_token{#1}
\peek_catcode:NF \c_math_superscript_token
{ \c_math_superscript_token\bullet }
}
\RenewDocumentCommand{\phipure}{}
{
\peek_catcode_remove:NTF \c_math_subscript_token
{
\@@_phipure_one:n
}
{\phi}
}
\RenewDocumentCommand{\mixing}{}{{MIX}}
\RenewDocumentCommand{\Deltamix}{m}
{\Delta\c_math_subscript_token\mixing #1}
\RenewDocumentCommand{\Deltarxn}{m}{\Delta #1}
\RenewDocumentCommand{\allbut}{O{j} m m}
{ \tl_if_eq:nnTF {#1} {#2}
{
{#3}\c_math_subscript_token k\neq{#3}\c_math_subscript_token{#2}
}
{
{#3}\c_math_subscript_token{#1}\neq{#3}\c_math_subscript_token{#2}
}
}
}
}
% \end{macrocode}
% We execute the default options below.
% \begin{macrocode}
\ExecuteOptions{EUAGHan,subscripts,parentheses,intensive-plain,moles-index}
\ProcessOptions
% \end{macrocode}
% We next encode a routine to sort non-subscripted variables into a consistent
% order. It currently does not sort variables with subscripts.
% \changes{v2.00}{2023/11/16}{Added a sorting routine to make function
% arguments be in a consistent order using the |nosubscripts| option.}
% \begin{macrocode}
\tl_const:Nn \c_@@_sort_order_tl
{\Et\Em\Es\Ut\Um\Us\Ht\Hm\Hs\Ft\Fm\Fs\Gt\Gm\Gs\Lt\Lm\Ls T\St\Sm\Ss
P\Vt\Vm\Vs\mu\Nt mwxyz\At\Am\As\sigma
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklnopqrstuvwxyz}
\clist_new:N \l_@@_in_list_clist
\clist_new:N \l_@@_sorted_list_clist
\clist_new:N \l_@@_remaining_list_clist
\cs_new:Nn \@@_sort_clist:n
{% Sort the list in the order of \c_@@_sort_order_tl
% Wipe out any remnants from the last sort
\clist_clear:N \l_@@_in_list_clist
\clist_clear:N \l_@@_sorted_list_clist
% Make a copy of the list
\clist_set:Nn \l_@@_remaining_list_clist {#1}
% Make a list of everything that's in the known sort order list
% and put everything else in the "not in sort order list" list.
\tl_map_inline:Nn \c_@@_sort_order_tl
{
\clist_if_in:NnT \l_@@_remaining_list_clist {##1}
{ \clist_put_right:Nn \l_@@_in_list_clist {##1} }
\clist_remove_all:Nn \l_@@_remaining_list_clist {##1}
}
% Then merge the lists back together again.
\clist_if_empty:NF \l_@@_in_list_clist
{
\clist_put_right:Nn \l_@@_sorted_list_clist \l_@@_in_list_clist
}
\clist_if_empty:NF \l_@@_remaining_list_clist
{
\clist_put_right:Nn \l_@@_sorted_list_clist \l_@@_remaining_list_clist
}
\clist_use:Nn \l_@@_sorted_list_clist ,
}
% \end{macrocode}
%
% \subsection{Commands for Partial Derivatives}
% The \cs{Partial} command and its second-order siblings are defined as below.
% They typeset partial derivatives of the first argument with respect to
% the second (and third, in the case of mixed second partial derivatives)
% arguments, holding the last argument constant.
%
% The starred forms adjust the spacing after the partial derivative so the
% trailing binary operator (assumed to be the same width as an equals sign)
% overhangs the variables held constant.
% We thus set \verb"operator_width" to be \emph{just} greater than the width of
% an equals sign.
% \begin{macrocode}
\dim_new:N \l_@@_Partial_const_dim
\dim_new:N \l_@@_operator_width_dim
\dim_new:N \l_@@_adjust_width_dim
\settowidth{\l_@@_operator_width_dim}{=}
\dim_set:Nn \l_@@_adjust_width_dim {0.1\l_@@_operator_width_dim}
\dim_add:Nn \l_@@_operator_width_dim \l_@@_adjust_width_dim
% \end{macrocode}
% \begin{macro}{\Partial}
% The command \cs{Partial} and its friends drastically simplify the creation
% of partial derivatives. The command \cs{Partial*} is the same as
% \cs{Partial} except that it adjusts the spacing so the (presumably) binary
% operator that follows it slightly overlaps the subscripts.
% \changes{v1.01}{2022/03/01}{Changed \cs{adjust@width} to 2pt (up from 1pt)}
% \changes{v1.01}{2022/04/21}{Changed \cs{adjust@width} 0.1\cs{operator@width}
% (from 2pt)}
% \changes{v2.00}{2023/11/16}{Changed length added to
% \cs{l_@@_Partial_const_dim} from $-0.15$ to $-0.20$}
% \begin{macrocode}
\tl_new:N \l_@@_Partial_start_tl
\tl_new:N \l_@@_Partial_end_tl
\tl_new:N \l_@@_Partial_empty_end_tl
\tl_new:N \l_@@_Partial_middle_tl
\tl_set:Nn \l_@@_Partial_start_tl {\left\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\right\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl {\right\l_@@_PartialEmptyClose_tl}
\tl_set:Nn \l_@@_Partial_middle_tl {\middle}
\cs_set_eq:NN \@@_frac:nn \frac
\NewDocumentCommand{\Partial}{s m m m}
{ \bool_if:nTF {#1}
{% Starred form (recursive)
\settowidth{\l_@@_Partial_const_dim}{\ensuremath{#4}}%
\dim_add:Nn \l_@@_Partial_const_dim {-0.20\l_@@_Partial_const_dim}%
\Partial{#2}{#3}{#4}%
\bool_if:NT \l_@@_subscripted_bool
{ \dim_compare:nNnTF \l_@@_operator_width_dim
< \l_@@_Partial_const_dim
{ \kern -\l_@@_operator_width_dim }
{ \kern -\l_@@_Partial_const_dim }
}
}
{% Unstarred form
\bool_if:NTF \l_@@_subscripted_bool
{% Handle case of empty variables held constant
\tl_if_eq:nnTF {#4} {}
{ \l_@@_Partial_start_tl
\@@_frac:nn{\partial #2}{\partial #3}\l_@@_Partial_empty_end_tl
}
{ \l_@@_Partial_start_tl\@@_frac:nn{\partial #2}
{\partial #3}\l_@@_Partial_end_tl
\c_math_subscript_token{#4}%
}
}
{% Check whether #4 contains \allNsbut{i} and #3 is \Nt_i
\tl_if_in:nnTF {#3} {\Nt}
{ \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}
\l_@@_Partial_start_tl
\@@_frac:nn{\partial #2(\@@_sort_clist:n{#4})}
{\partial #3}\l_@@_Partial_end_tl
}
{ \l_@@_Partial_start_tl
\@@_frac:nn{\partial #2(\@@_sort_clist:n{#3,#4})}
{\partial #3}\l_@@_Partial_end_tl
}
}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PartialBigg}
% The \cs{PartialBigg} macro (and its starred form) replace the \tn{left}
% and \tn{right} commands in \cs{Partial} with \pkg{amsmath}'s \tn{Biggl}
% and \tn{Biggr} variants. The starred form is inherited from \cs{Partial}
% without modification.
% \begin{macrocode}
\NewDocumentCommand{\PartialBigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\Biggl\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\Biggr\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_Empty_end_tl
{\Biggr\l_@@_PartialEmptyClose_tl}
\Partial
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Partialbigg}
% The \cs{Partialbigg} macro does the same thing as \cs{PartialBigg}, except
% using \pkg{amsmath}'s \tn{biggl}/\tn{biggr} variants.
% \begin{macrocode}
\NewDocumentCommand{\Partialbigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\biggr\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl
{\biggr\l_@@_PartialEmptyClose_tl}
\Partial
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PartialSecond}
% The second partial derivatives are defined similarly to \cs{Partial}.
% \begin{macrocode}
\NewDocumentCommand{\PartialSecond}{s m m m}
{
\bool_if:nTF {#1}
{% Starred form
\settowidth{\l_@@_Partial_const_dim}{\ensuremath{#4}}%
\dim_add:Nn \l_@@_Partial_const_dim {-0.20\l_@@_Partial_const_dim}
\PartialSecond{#2}{#3}{#4}%
\bool_if:nT \l_@@_subscripted_bool
{ \dim_compare:nNnTF {\l_@@_operator_width_dim}
< {\l_@@_Partial_const_dim}
{ \kern -\l_@@_operator_width_dim }
{ \kern -\l_@@_Partial_const_dim }
}
}
{% Unstarred form
\bool_if:NTF \l_@@_subscripted_bool
{% Handles case of empty variables held constant
\tl_if_eq:nnTF {#4} {}
{ \l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2 #2}
{\partial #3\c_math_superscript_token 2}\l_@@_Partial_empty_end_tl
}
{ \l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2 #2}
{\partial #3\c_math_superscript_token 2}\l_@@_Partial_end_tl
\c_math_subscript_token{#4}%
}
}
{% Check whether #4 contains \allNsbut{i} and #3 is \Nt_i
\tl_if_in:nnTF {#2} {\Nt}
{ \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2 #2(#4)}
{\partial\c_math_superscript_token 2 #3}\l_@@_Partial_end_tl
}
{ \l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2
#2(\@@_sort_clist:n{#3,#4})}
{\partial #3\c_math_superscript_token 2}\l_@@_Partial_end_tl
}
}
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\PartialSecondBigg}
% The \cs{PartialSecondBigg} macro and its starred variant replace \cs{left}
% and \tn{right} with \pkg{amsmath}'s \cs[module=amsmath]{Biggl} and
% \cs[module=amsmath]{Biggr}.
% \begin{macrocode}
\NewDocumentCommand{\PartialSecondBigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\biggl\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl {\biggl\l_@@_PartialClose_tl}
\PartialSecond
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\PartialSecondbigg}
% The \cs{PartialSecondbigg} macro and its starred variant replace \tn{left}
% and \tn{right} with \pkg{amsmath}'s \cs[module=amsmath]{biggl} and
% \cs[module=amsmath]{biggr}.
% \begin{macrocode}
\NewDocumentCommand{\PartialSecondbigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\biggl\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl {\biggl\l_@@_PartialClose_tl}
\PartialSecond
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PartialMixSecond}
% The macro \cs{PartialMixSecond} takes an extra argument, but is otherwise
% the same as its same-variable cousin.
% \begin{macrocode}
\bool_new:N \l_@@_has_x_or_y_bool
\NewDocumentCommand{\PartialMixSecond}{s m m m m}
{
\bool_if:nTF {#1}
{% Starred version
\settowidth{\l_@@_Partial_const_dim}{\ensuremath{#4}}%
\dim_add:Nn \l_@@_Partial_const_dim {-0.20\l_@@_Partial_const_dim}
\PartialMixSecond{#2}{#3}{#4}{#5}
\bool_if:nT \l_@@_subscripted_bool
{ \dim_compare:nNnTF {\l_@@_operator_width_dim}
< {\l_@@_Partial_const_dim}
{ \kern -\l_@@_operator_width_dim }
{ \kern -\l_@@_Partial_const_dim }
}
}
{% Unstarred version
\bool_if:nTF \l_@@_subscripted_bool
{% subscripted version
\tl_if_eq:nnTF {#5} {}
{% Handle case of empty variables held constant
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2 #2}
{\partial #3\partial #4}\l_@@_Partial_empty_end_tl
}
{ \l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2 #2}
{\partial #3\partial #4}\l_@@_Partial_end_tl
\c_math_subscript_token{#5}
}
}
{% not subscripted
\tl_if_eq:nnTF {#5} {}
{% empty argument
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2
#2(\@@_sort_clist:n{#3,#4,#5})}
{\partial #3\partial #4}\l_@@_Partial_empty_end_tl
}
{% Check whether #3 OR #4 are \Nt_i/etc.
\tl_if_in:nnTF {#3} {\Nt}
{ \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}%
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2
#2(\@@_sort_clist:n{#4,#5})}
{\partial #3\partial #4}\l_@@_Partial_end_tl
}
{ \tl_if_in:nnTF {#4} {\Nt}
{ \RenewDocumentCommand{\allbut}{O{j} m m}{\allcomponents{##3}}%
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2
#2(\@@_sort_clist:n{#3,#5})}
{\partial #3\partial #4}\l_@@_Partial_end_tl
}
{% Check for x, y, or w
\bool_set_false:N \l_@@_has_x_or_y_bool
\tl_if_in:nnT {#3} {x}
{ \l_@@_has_x_or_y_bool }
\tl_if_in:nnT {#3} {y}
{ \l_@@_has_x_or_y_bool }
\tl_if_in:nnT {#3} {w}
{ \l_@@_has_x_or_y_bool }
\bool_if:NTF \l_@@_has_x_or_y_bool
{ \RenewDocumentCommand{\allbutlastand}{O{j} m m}
{\allcomponents{##3}}
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2
#2(\@@_sort_clist:n{#4,#5})}
{\partial #3\partial #4}\l_@@_Partial_end_tl
}
{
\l_@@_Partial_start_tl
\@@_frac:nn{\partial\c_math_superscript_token 2
#2(\@@_sort_clist:n{#3,#4,#5})}
{\partial #3\partial #4}\l_@@_Partial_end_tl
}
}
}
}
}
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\PartialMixSecondBigg,\PartialMixSecondbigg}
% The macro \cs{PartialMixSecondBigg} is analogous to the aforementioned macros
% \cs{PartialBigg} and \cs{PartialSecondBigg}. \cs{PartialMixSecondbigg} is
% analogous to \cs{Partialbigg} and \cs{PartialSecondbigg}.
% \begin{macrocode}
\NewDocumentCommand{\PartialMixSecondBigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\Biggl\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\Biggl\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl {\Biggl\l_@@_PartialClose_tl}
\PartialMixSecond
}
\NewDocumentCommand{\PartialMixSecondbigg}{}
{ \tl_set:Nn \l_@@_Partial_start_tl {\biggl\l_@@_PartialOpen_tl}
\tl_set:Nn \l_@@_Partial_end_tl {\biggl\l_@@_PartialClose_tl}
\tl_set:Nn \l_@@_Partial_empty_end_tl {\biggl\l_@@_PartialClose_tl}
\PartialMixSecond
}
% \end{macrocode}
%
% If the user does not load the \pkg{amsmath} package, we will not have access
% to \cs[module=amsmath]{Biggl}, \cs{Biggr}, \cs{biggl}, and \cs{biggr}, so we revert them back
% to the ordinary \cs{left} and \cs{right} versions and warn the user.
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{amsmath}{}{%
\PackageWarningNoLine{thermodynamics}
{Package~amsmath~not~loaded;~load~to~make~PartialBigg~and~friends
~work~correctly}%
\cs_set_eq:NN \PartialBigg \Partial
\cs_set_eq:NN \Partialbigg \Partial
\cs_set_eq:NN \PartialSecondBigg \PartialSecond
\cs_set_eq:NN \PartialSecondbigg \PartialSecond
\cs_set_eq:NN \PartialMixSecondBigg \PartialMixSecond
\cs_set_eq:NN \PartialMixSecondbigg \PartialMixSecond
\ProvideDocumentCommand{\rvert}{}{|}
\ProvideDocumentCommand{\lvert}{}{|}
}%
}
% \end{macrocode}
% \end{macro}
% \changes{v1.01}{2023/09/15}{Added \cs{Partialinline} and friends to
% facilitate in-line (non-display-mode) partial derivatives, with
% corresponding changes to \cs{Partial} and friends for ease of
% implementation. Also added \cs{Partialinlinetext} and friends for
% non-expanding delimiters.}
% \begin{macro}{\Partialinline,\PartialSecondinline,\PartialMixSecondinline}
% Inline partial derivatives.
% \begin{macrocode}
\NewDocumentCommand{\Partialinline}{}
{
\cs_set:Nn \@@_frac:nn { ##1 \l_@@_Partial_middle_tl / ##2 }
\Partial
}
\NewDocumentCommand{\PartialSecondinline}{}
{
\cs_set:Nn \@@_frac:nn { ##1 \l_@@_Partial_middle_tl / ##2 }
\PartialSecond
}
\NewDocumentCommand{\PartialMixSecondinline}{}
{
\cs_set:Nn \@@_frac:nn { ##1 \l_@@_Partial_middle_tl / ##2 }
\PartialMixSecond
}
% \end{macrocode}
% \end{macro}
% \pagebreak[1]
% \setmarginparsize{\footnotesize}
% \begin{macro}{\Partialinlinetext}
% \begin{macro}{\PartialSecondinlinetext}
% \begin{macro}{\PartialMixSecondinlinetext}
% Text-only (non-extensible delimiter) versions of \cs{Partialinline}
% and friends.
%^^A TODO: These currently "pollute" other partial derivatives until the end
%^^A of the line (i.e., \Partialinline{z}{x}{y} = \Partial{z}{x}{y} will
%^^A produce identical things on both sides). For now, it's a "feature."
% \begin{macrocode}
\NewDocumentCommand{\Partialinlinetext}{}
{ \cs_set_eq:NN \l_@@_Partial_start_tl \l_@@_PartialOpen_tl
\cs_set_eq:NN \l_@@_Partial_end_tl \l_@@_PartialClose_tl
\cs_set_eq:NN \l_@@_Partial_empty_end_tl \l_@@_PartialEmptyClose_tl
\cs_set_eq:NN \l_@@_Partial_middle_tl \relax
\Partialinline
}
\NewDocumentCommand{\PartialSecondinlinetext}{}
{ \cs_set_eq:NN \l_@@_Partial_start_tl \l_@@_PartialOpen_tl
\cs_set_eq:NN \l_@@_Partial_end_tl \l_@@_PartialClose_tl
\cs_set_eq:NN \l_@@_Partial_empty_end_tl \l_@@_PartialEmptyClose_tl
\cs_set_eq:NN \l_@@_Partial_middle_tl \relax
\PartialSecondinline
}
\NewDocumentCommand{\PartialMixSecondinlinetext}{}
{ \cs_set_eq:NN \l_@@_Partial_start_tl \l_@@_PartialOpen_tl
\cs_set_eq:NN \l_@@_Partial_end_tl \l_@@_PartialClose_tl
\cs_set_eq:NN \l_@@_Partial_empty_end_tl \l_@@_PartialEmptyClose_tl
\cs_set_eq:NN \l_@@_Partial_middle_tl \relax
\PartialMixSecondinline
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \restoremarginparsize
%
% \subsection{Local Override of Delimiters}
% We define several environments that \emph{locally} override the delimiters on
% partial derivatives generated with \cs{Partial} and friends, the
% subscript notation for partial derivatives, and/or the definitions of
% range-oriented macros such as \cs{allNs}. These environments can be nested;
% the inner-most one will be honored if conflicts occur.
% \begin{environment}{thermoparentheses}
% Inside this environment, partial derivatives will have parentheses around
% them, regardless of package options.
% \begin{macrocode}
\NewDocumentEnvironment{thermoparentheses}{}
{ \cs_set:Nn \l_@@_PartialOpen_tl {(}
\cs_set:Nn \l_@@_PartialClose_tl {)}
\cs_set:Nn \l_@@_PartialEmptyClose_tl {)}
}{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermobrackets}
% Inside this environment, partial derivatives will have brackets around
% them, regardless of package options.
% \begin{macrocode}
\NewDocumentEnvironment{thermobrackets}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {[}
\tl_set:Nn \l_@@_PartialClose_tl {]}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {]}
}{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermobraces}
% Inside this environment, partial derivatives will have braces around
% them, regardless of package options.
% \begin{macrocode}
\NewDocumentEnvironment{thermobraces}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {\{}
\tl_set:Nn \l_@@_PartialClose_tl {\}}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {\}}
}{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermobar}
% Inside this environment, partial derivatives will have a trailing vertical
% bar, regardless of package options.
% \begin{macrocode}
\NewDocumentEnvironment{thermobar}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {.}
\tl_set:Nn \l_@@_PartialClose_tl {\rvert}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
}{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermoplain}
% Inside this environment, partial derivatives will have no decorations
% around them, regardless of package options.
% \begin{macrocode}
\NewDocumentEnvironment{thermoplain}{}
{ \tl_set:Nn \l_@@_PartialOpen_tl {.}
\tl_set:Nn \l_@@_PartialClose_tl {.}
\tl_set:Nn \l_@@_PartialEmptyClose_tl {.}
\bool_set_false:N \l_@@_subscripted_bool
}{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermoNOsubscripts}
% Inside this environment, subscripts will not be displayed to the right of
% partial derivatives, regardless of package options.
% \begin{macrocode}
\NewDocumentEnvironment{thermoNOsubscripts}{}
{\bool_set_false:N \l_@@_subscripted_bool}
{}
% \end{macrocode}
% \begin{environment}{thermosubscripts}
% Inside this environment, subscripts will be displayed to the right of
% partial derivatives, regardless of package options.
% \end{environment}
% \begin{macrocode}
\NewDocumentEnvironment{thermosubscripts}{}
{\bool_set_true:N \l_@@_subscripted_bool}
{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermomolesrange}
% Inside this environment, the macro \cs{allNs} will expand to
% $n_1,\dotsc,n_C$ (or equivalent symbols if \cs{Nt} and/or \cs{ncomponents}
% have been redefined), regardless of package options. Similar expansions will
% result for \cs{allXs}, \cs{allYs}, \cs{allMs}, and so on.
% \changes{v2.00}{2023/11/16}{Added environment to invoke the ``moles-range''
% definitions of \cs{allNs} and friends locally.}
% \begin{macrocode}
\NewDocumentEnvironment{thermomolesrange}{}
{ \@@_set_moles_range }
{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermointensiveplain}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
% ``intensive-plain'' option locally.}
% \begin{macrocode}
% \begin{macrocode}
\NewDocumentEnvironment{thermointensiveplain}{}
{ \@@_set_intensive_plain }
{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermoextensiveplain}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
% ``extensive-plain'' option locally.}
% \begin{macrocode}
\NewDocumentEnvironment{thermoextensiveplain}{}
{ \@@_set_extensive_plain }
{}
% \end{macrocode}
% \end{environment}
% \setmarginparsize{\scriptsize}
% \begin{environment}{thermointensivelowercase}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
% ``intensive-lowercase'' option locally.}
% \begin{macrocode}
\NewDocumentEnvironment{thermointensivelowercase}{}
{% {
% \RenewExpandableDocumentCommand{\MacroFont}{}{
% \fontencoding\encodingdefault
% \fontfamily\ttdefault
% \fontseries\mddefault
% \fontshape\shapedefault
% \footnotesize}
\@@_set_intensive_lowercase
\@@_set_lowercase_pms
}
{}
% \end{macrocode}
% \end{environment}
% \begin{environment}{thermoextensivesuperscript}
% \changes{v2.00}{2023/11/16}{Added environment to invoke the
% ``extensive-superscript'' option locally.}
% \begin{macrocode}
\NewDocumentEnvironment{thermoextensivesuperscript}{}
{
\@@_set_extensive_superscripts
}
{}
% \end{macrocode}
% \end{environment}
% \restoremarginparsize
%
% \subsection{User-Interface Macros to Define Symbols}
% \begin{macro}{\NewSubscriptedSymbol}
% First, we define a command that serves to create ``subscripted''
% symbols; for example, typing \verb"\cP_i" should yield $C_{P,i}$ rather
% than $C_{Pi}$, ${C_P}_i$, or ${C_{P_i}}$. Superscripts are also handled
% properly and can be in either order.
% \changes{v2.00}{2023/11/16}{Deleted \cs{DeclareSubscriptedSymbol} in favor
% of \pkg{xparse}-based \cs{NewSubscriptedSymbol} and
% \cs{RenewSubscriptedSymbol}.}
% \begin{macrocode}
\cs_new:Npn \@@_check_definable:nN #1#2
{
\bool_set_true:N \l_@@_arg_legal_bool
\tl_trim_spaces_apply:nN {#1} \tl_if_single_token:nTF
{
\str_set:Nx \l_tmp_str {\tl_to_str:n {#1}}
\int_compare:nNnT {\str_count:N \l_tmp_str} = 1
{ \PackageError{thermodynamics}
{First~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
must~be~a~command}
{The~first~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
should~be~the~macro~that~will~be~used~to~refer~to~the~symbol.~
The~provided~argument~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~
is~a~single~character.
\MessageBreak Perhaps~a~backslash~is~missing?}
}
}
{ \PackageError{thermodynamics}
{First~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
must~be~a~command}
{The~first~argument~of~'\tl_trim_spaces:o {\tl_to_str:n {#2}}'~
should~be~the~macro~that~will~be~used~to~refer~to~the~symbol.~
The~provided~argument~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~
contains~more~than~one~token.
\MessageBreak Perhaps~a~backslash~is~missing?}
}
}
\NewDocumentCommand{\NewSubscriptedSymbol}{m m m}
{
\@@_check_definable:nN {#1} \NewSubscriptedSymbol
\cs_if_exist:NT #1
{ \PackageError{thermodynamics}
{Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~already~defined}
{You~have~used~
'\tl_trim_spaces:o {\tl_to_str:n {\NewSubscriptedSymbol}}'~
with~a~command~that~already~has~a~definition}
}
\cs_new:cpn {\cs_to_str:N #1_one:n} ##1
{
{#2}\c_math_superscript_token{##1}
\peek_catcode_remove:NTF \c_math_subscript_token
{ \use:c {\cs_to_str:N #1_three:n} }
{ \c_math_subscript_token{#3} }
}
\cs_new:cpn {\cs_to_str:N #1_two:n} ##1
{ {#2}\c_math_subscript_token{#3,##1} }
\cs_new:cpn {\cs_to_str:N #1_three:n} ##1
{ \c_math_subscript_token{#3,##1} }
\NewDocumentCommand{#1}{}
{% @branch
\peek_catcode_remove:NTF \c_math_superscript_token
{ \use:c {\cs_to_str:N #1_one:n} }
{ \peek_catcode_remove:NTF \c_math_subscript_token
{ \use:c {\cs_to_str:N #1_two:n} }
{ {#2}\c_math_subscript_token{#3} }
}
}
}
\NewDocumentCommand{\RenewSubscriptedSymbol}{m m m}
{
\@@_check_definable:nN {#1} \RenewSubscriptedSymbol
\cs_if_exist:NF #1
{ \PackageError{thermodynamics}
{Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~not~defined}
{You~have~used~
'\tl_trim_spaces:o {\tl_to_str:n {\RenewSubscriptedSymbol}}'~
with~a~command~that~does~not~have~a~definition}
}
\cs_set:cpn {\cs_to_str:N #1_one:n} ##1
{
{#2}\c_math_superscript_token{##1}
\peek_catcode_remove:NTF \c_math_subscript_token
{ \use:c {\cs_to_str:N #1_three:n} }
{ \c_math_subscript_token{#3} }
}
\cs_set:cpn {\cs_to_str:N #1_two:n} ##1
{ {#2}\c_math_subscript_token{#3,##1} }
\cs_set:cpn {\cs_to_str:N #1_three:n} ##1
{ \c_math_subscript_token{#3,##1} }
\RenewDocumentCommand{#1}{}
{% @branch
\peek_catcode_remove:NTF \c_math_superscript_token
{ \use:c {\cs_to_str:N #1_one:n} }
{ \peek_catcode_remove:NTF \c_math_subscript_token
{ \use:c {\cs_to_str:N #1_two:n} }
{ {#2}\c_math_subscript_token{#3} }
}
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\NewSuperscriptedSymbol}
% \changes{v2.00}{2023/11/16}{Created \cs{NewSuperscriptedSymbol} to handle
% superscripted excess and residual properties without intervention.}
% \begin{macrocode}
\NewDocumentCommand{\NewSuperscriptedSymbol}{m m m}
{
\@@_check_definable:nN {#1} \NewSuperscriptedSymbol
\cs_if_exist:NT #1
{ \PackageError{thermodynamics}
{Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~already~defined}
{You~have~used~
'\tl_trim_spaces:o {\tl_to_str:n {\NewSuperscriptedSymbol}}'~
with~a~command~that~already~has~a~definition}
}
\cs_new:cpn {\cs_to_str:N #1_one:n} ##1
{
{#2}\c_math_subscript_token{#1}
\peek_catcode_remove:NTF \c_math_superscript_token
{ \use:c {\cs_to_str:N #1_one:n} }
{ \c_math_subscript_token{#3} }
}
\cs_new:cpn {\cs_to_str:N #1_two:n} ##1
{ {#2}\c_math_superscript_token{#3,##1} }
\cs_new:cpn {\cs_to_str:N #1_three:n} ##1
{ {#2}\c_math_superscript_token{#3,##1} }
\NewDocumentCommand{#1}{}
{
\peek_catcode_remove:NTF \c_math_subscript_token
{ \use:c {\cs_to_str:N #1_one:n} }
{ \peek_catcode_remove:NTF \c_math_superscript_token
{ \use:c {\cs_to_str:N #1_two:n} }
{ {#2}\c_math_superscript_token{#3} }
}
}
}
\NewDocumentCommand{\RenewSuperscriptedSymbol}{m m m}
{
\@@_check_definable:nN {#1} \RenewSuperscriptedSymbol
\cs_if_exist:NF #1
{ \PackageError{thermodynamics}
{Command~'\tl_trim_spaces:o {\tl_to_str:n {#1}}'~not~defined}
{You~have~used~
'\tl_trim_spaces:o {\tl_to_str:n {\RenewSuperscriptedSymbol}}'~
with~a~command~that~does~not~have~a~definition}
}
\cs_set:cpn {\cs_to_str:N #1_one:n} ##1
{
{#2}\c_math_subscript_token{##1}
\peek_catcode_remove:NTF \c_math_superscript_token
{ \use:c {\cs_to_str:N #1_three:n} }
{ \c_math_superscript_token{#3} }
}
\cs_set:cpn {\cs_to_str:N #1_two:n} ##1
{ {#2}\c_math_superscript_token{#3,##1} }
\cs_set:cpn {\cs_to_str:N #1_three:n} ##1
{ \c_math_superscript_token{#3,##1} }
\RenewDocumentCommand{#1}{}
{% @branch
\peek_catcode_remove:NTF \c_math_subscript_token
{ \use:c {\cs_to_str:N #1_one:n} }
{ \peek_catcode_remove:NTF \c_math_superscript_token
{ \use:c {\cs_to_str:N #1_two:n} }
{ {#2}\c_math_superscript_token{#3} }
}
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\heatcapacitysymbol,\compressibilitysymbol,\expansivitysymbol}
% Now we define symbols for the heat capacities, compressibilities, and
% so forth.
% \begin{macrocode}
\NewExpandableDocumentCommand{\heatcapacitysymbol}{}{C}
\NewExpandableDocumentCommand{\compressibilitysymbol}{}{\kappa}
\NewExpandableDocumentCommand{\expansivitysymbol}{}{\alpha}
\NewExpandableDocumentCommand{\JTsymbol}{}{\mu}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\cV,\cP}
% The heat capacities are molar by default; we also declare extensive and
% specific heat capacities.
% The heat capacities themselves are defined to be ``smart'': \verb"\cV_i" will
% recognize the subscript appropriately and render $C_{V,i}$ rather than
% ${C_V}_i$ or some other unintended symbol. Superscripts are also handled
% appropriately and can be in either order.
% \begin{macrocode}
\NewSubscriptedSymbol{\cV}{\@@_intensive:n \heatcapacitysymbol}
{\g_@@_volume_symbol}
\NewSubscriptedSymbol{\cP}{\@@_intensive:n \heatcapacitysymbol}
{\g_@@_pressure_symbol}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\cVt,\cPt}
% We also introduce \emph{extensive} (rather than molar) heat capacity macros.
% \begin{macrocode}
\NewSubscriptedSymbol{\cVt}{\@@_extensive:n \heatcapacitysymbol}
{\g_@@_volume_symbol}
\NewSubscriptedSymbol{\cPt}{\@@_extensive:n \heatcapacitysymbol}
{\g_@@_pressure_symbol}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\cVs,\cPs}
% \cs{cPs} and \cs{cVs} are the specific heat capacities.
% \begin{macrocode}
\NewSubscriptedSymbol{\cVs}{\@@_specific:n \heatcapacitysymbol}
{\g_@@_volume_symbol}
\NewSubscriptedSymbol{\cPs}{\@@_specific:n \heatcapacitysymbol}
{\g_@@_pressure_symbol}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\kappaT,\kappaS}
% The isothermal and adiabatic compressibilities are defined similarly, but
% those do not have extensive versions for obvious reasons.
% \begin{macrocode}
\NewSubscriptedSymbol{\kappaT}{\compressibilitysymbol}
{\g_@@_temperature_symbol}
\NewSubscriptedSymbol{\kappaS}{\compressibilitysymbol}
{\g_@@_entropy_symbol}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\alphaP,\alphaS}
% The macro \cs{alphaP} is intended to refer to the isobaric volume
% expansivity, while \cs{alphaS} is the isentropic volume expansivity.
% \begin{macrocode}
\NewSubscriptedSymbol{\alphaP}{\expansivitysymbol}{\g_@@_pressure_symbol}
\NewSubscriptedSymbol{\alphaS}{\expansivitysymbol}{\g_@@_entropy_symbol}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\muJT}
% The macro \cs{muJT} renders the Joule--Thomson coefficient.
% \begin{macrocode}
\NewSubscriptedSymbol{\muJT}{\JTsymbol}{JT}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Psat,\Pvap,\phisat,\fsat,\sat}
% The \cs{Psat} macro (and its clone, the \cs{Pvap} macro) should be used for
% the saturation pressure.
% Similarly, a \cs{phisat} macro typesets the fugacity coefficient at
% saturation. The \cs{fsat} macro similarly renders the fugacity at saturation.
% Other saturation properties should use \verb"M^\sat" or similar, preferably
% by defining another macro such as \verb"\Gmsat".
% \begin{macrocode}
\NewDocumentCommand{\sat}{}{{\text{sat}}}
\NewDocumentCommand{\Psat}{}{P\c_math_superscript_token\sat}
\NewDocumentCommand{\Pvap}{}{\Psat}
\NewDocumentCommand{\phisat}{}{\phi\c_math_superscript_token\sat}
\NewDocumentCommand{\fsat}{}{\fpure\c_math_superscript_token\sat}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\std,\Pstd,\fstd}
% The \cs{std} macro denotes standard properties. \cs{Pstd} and \cs{fstd} are
% defined for convenience and for consistency across textbooks.
% \begin{macrocode}
\NewDocumentCommand{\std}{}{\circ}
\NewDocumentCommand{\Pstd}{}{P\c_math_superscript_token \std}
\NewDocumentCommand{\fstd}{}{f\c_math_superscript_token \std}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Deltamix,\mixing}
% Mixing properties, such as $\Deltamix\Gm$, should be accessed using
% \verb"\Deltamix\Gm" and similar constructions---this construct will typeset
% as $\Delta_{MIX}G$ using the |Thompson| package option, for example,
% and as $\Delta_\text{mix}\Gt$ using the |Sandler| package option.
% \begin{macrocode}
\NewDocumentCommand{\mixing}{}{{\text{mix}}}
\NewDocumentCommand{\Deltamix}{m}
{\Delta{#1}\c_math_subscript_token\mixing}
% \end{macrocode}
% \end{macro}
%
% \pagebreak[2]%
% \begin{macro}{\Deltafus,\fusion,\Deltavap,\vaporization}
% \begin{macro}{\Deltasub,\sublimation,\Deltarxn,\reaction}
% Similar entities for property changes on fusion, reaction, sublimation, and
% vaporization are defined.
% \begin{macrocode}
\NewDocumentCommand{\fusion}{}{{\text{fus}}}
\NewDocumentCommand{\reaction}{}{{\text{rxn}}}
\NewDocumentCommand{\sublimation}{}{{\text{sub}}}
\NewDocumentCommand{\vaporization}{}{{\text{vap}}}
\NewDocumentCommand{\formation}{}{f}
\NewDocumentCommand{\Deltafus}{m}
{\Delta #1\c_math_superscript_token\fusion}
\NewDocumentCommand{\Deltasub}{m}
{\Delta #1\c_math_superscript_token\sublimation}
\NewDocumentCommand{\Deltavap}{m}
{\Delta #1\c_math_superscript_token\vaporization}
\NewDocumentCommand{\Deltarxn}{m}
{\Delta #1\c_math_subscript_token\reaction}
\tl_new:N \l_@@_Deltaf_sym_tl
\NewSubscriptedSymbol{\@@_Deltaf}{\l_@@_Deltaf_sym_tl}{f}
\NewDocumentCommand{\Deltaf}{m}
{ \tl_set:Nn \l_@@_Deltaf_sym_tl {\Delta #1}
\@@_Deltaf
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fmix}
% The \cs{fmix} command is intended to describe fugacities in mixtures.
% It renders as $\hat f$ by default, and would be used as \verb"\fmix_i" or
% the like, producing $\hat f_i$; some authors like to use $\bar f_i$ or
% just $f_i$, and this command creates a consistent way to change between
% such options.
% \begin{macrocode}
\NewDocumentCommand{\fmix}{}{\hat{f}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\phimix}
% A similar command, \cs{phimix}, renders $\hat\phi$ by default to represent
% the fugacity coefficient in the mixture.
% \begin{macrocode}
\NewDocumentCommand{\phimix}{}{\hat\phi}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\fpure}
% The \cs{fpure} command is intended to describe fugacities in pure substances.
% It renders as $f$ by default, and would be used as \verb"\fpure" or
% \verb"\fpure_i" or the like, producing $f_i$; some authors like to use
% $f_{\text{pure},i}$, and others like to use $f_i^\bullet$; this command
% creates a consistent way to change between the these options. A similar
% command for $\phi$ is given, \cs{phipure}, for fugacity coefficients.
% \begin{macrocode}
\NewDocumentCommand{\fpure}{}{f}
\NewDocumentCommand{\phipure}{}{\phi}
% \end{macrocode}
% \end{macro}
%
% \subsection{Partial Molar Quantities}
% \begin{macro}{\partialmolar}
% Partial molar quantities with superscripts appear as $\Gpm[\IG]{i}$ or
% $\GRpm{i}$, rather than something like
% $\overline{G}^\IG_i$ or $\overline{G}_i^R$; the former looks better but
% is harder to implement for obvious reasons. Their definitions allow them to
% be used as symbols, something like \verb"\Gpm_i", \verb"\Gpm^{\IGM}_i",
% \verb"\Gpm^{\IGM}_i", and even \verb"\Gpm_i^{\IGM}";
% they can also be treated as commands: \verb"\Gpm{i}" is equivalent to
% \verb"\Gpm_i" and \verb"\Gpm[\IGM]{i}" is equivalent to \verb"\Gpm_i^{\IGM}".
% The macro \cs{partialmolar} can be used to create an arbitrary partial
% molar symbol.
% \begin{macrocode}
\tl_new:N \l_@@_pm_symbol_tl
\tl_new:N \l_@@_pm_arg_tl
\NewDocumentCommand{\partialmolar}{m}
{
\tl_set:Nn \l_@@_pm_symbol_tl {#1}
\@@_generic_pm:
}
%% cases to consider:
%% (1) \Mpm{i}
%% (2) \Mpm[S]{i}
%% (3) \Mpm^S_i
%% (4) \Mpm_i^S
%% (5) \Mpm_i
%% note that \Mpm^S with no subscript makes no sense and is thus forbidden
\cs_new:Nn \@@_generic_pm:
{
\peek_catcode_remove:NTF \c_math_subscript_token
{% case 4 or case 5
\@@_pm_case_four_or_five
}
{% look for superscript token
\peek_catcode_remove:NTF \c_math_superscript_token
{% case 3: \Mpm^{#1}_{#2} or \Mpm^{#1}{#2}
\@@_pm_case_three
}
{% Look for optional argument [...]
\peek_charcode:NTF [
{% case 2: \Mpm[S]{i}
\@@_pm_case_two
}
{% case 1: \Mpm{i}
\@@_pm_case_one
}
}
}
}
\cs_new:Npn \@@_pm_case_one #1
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token{#1}}
}
\cs_new:Npn \@@_pm_case_two [#1]#2
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{#1}\c_math_subscript_token{#2}}
}
\cs_new:Npn \@@_pm_case_three #1
{
\tl_set:Nn \l_@@_pm_arg_tl {#1}
\peek_catcode_remove:NTF \c_math_subscript_token
{ \@@_pm_case_three_part_two }
{ \@@_pm_case_three_part_two }
}
\cs_new:Npn \@@_pm_case_three_part_two #1
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{\l_@@_pm_arg_tl}
\c_math_subscript_token{#1}}
}
\cs_new:Npn \@@_pm_case_four_or_five #1
{
\tl_set:Nn \l_@@_pm_arg_tl {#1}
\peek_catcode_remove:NTF \c_math_superscript_token
{ \@@_pm_case_four }
{ \@@_pm_case_five }
}
\cs_new:Npn \@@_pm_case_four #1
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_superscript_token{#1}
\c_math_subscript_token{\l_@@_pm_arg_tl}}
}
\cs_new:Npn \@@_pm_case_five
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_subscript_token{\l_@@_pm_arg_tl}}
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Symbol Definitions}
% These macros define the user interface to the symbols for energy, volume,
% and so forth. There are five commands that define thermodynamic properties.
%
% \begin{macro}{\NewExtensiveProperty}
% The command \cs{NewExtensiveProperty} declares macros for a total, molar, and
% specific version of the symbol; for example, a second heat-like property
% could be defined via
% \begin{verbatim}
% \NewExtensiveProperty{R}{\mathcal{Q}}
%\end{verbatim}
% \NewExtensiveProperty{R}{\mathcal{Q}}\relax
% The command above would declare the macros \cs{Rt}, \cs{Rm}, and \cs{Rs}
% that expand to $\Rt$, $\Rm$, and $\Rs$, respectively, using the default
% package options.
% \end{macro}
%
% \begin{macro}{\NewPartialMolarProperty}
% The command \cs{NewPartialMolarProperty} declares a macro for the partial
% molar quantity. For example,
% \begin{verbatim}
% \NewPartialMolarProperty{I}{\Psi}
%\end{verbatim}
% \NewPartialMolarProperty{I}{\Psi}\relax
% would create the command \cs{Ipm}, which would typeset a partial molar
% command with the base symbol $\Psi$, yielding $\Ipm{i}$.
% \end{macro}
%
% \begin{macro}{\NewThermodynamicProperty}
% Declaring a new potential is handled by the
% \cs{NewThermodynamicProperty} macro, which takes two arguments. The first
% is the base of the name, and the second is the base of the symbol. This
% declares four new commands for the extensive, molar, specific, and partial
% molar properties. These commands consist of the first argument followed by
% \verb"t", \verb"m", \verb"s", and \verb"pm", respectively. For example, one
% might define the entropy via
% \begin{verbatim}
% \NewThermodynamicProperty{S}{S}
%\end{verbatim}
% and it would define the macros \cs{St}, \cs{Sm}, \cs{Ss}, and \cs{Spm} that
% yield, respectively, $\St$, S, $\hat S$, and $\Spm{i}$ (assuming the
% subscript to the partial molar quantity was $i$).
% It would also declare residual and excess properties for that base symbol.
% Note that the actual definition of the entropy and the other standard
% properties is slightly more complicated so as to allow for different symbols
% to be used in different textbooks.
% \begin{macrocode}
\NewDocumentCommand{\NewThermodynamicProperty}{m m}
{
\NewExtensiveProperty{#1}{#2}
\NewPartialMolarProperty{#1}{#2}
\NewResidualProperty{#1}{#2}
\NewExcessProperty{#1}{#2}
}
\NewDocumentCommand{\NewExtensiveProperty}{m m}
{
% Extensive property
\exp_after:wN \NewDocumentCommand \exp_after:wN
{\cs:w #1t\cs_end:}{}{\@@_extensive:n {#2}}
% Molar property
\exp_after:wN \NewDocumentCommand \exp_after:wN
{\cs:w #1m\cs_end:}{}{\@@_intensive:n {#2}}
% Specific property
\exp_after:wN \NewDocumentCommand \exp_after:wN
{\cs:w #1s\cs_end:}{}{\@@_specific:n {#2}}
}
\NewDocumentCommand{\NewPartialMolarProperty}{m m}
{
% Partial molar property
\exp_after:wN \NewDocumentCommand \exp_after:wN
{\cs:w #1pm\cs_end:}{}{\partialmolar{#2}}
}
\NewDocumentCommand{\NewExcessProperty}{m m}
{
\exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
{\cs:w #1 Et\cs_end:}{\@@_extensive:n{#2}}{\excess}
\exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
{\cs:w #1 E\cs_end:}{\@@_intensive:n{#2}}{\excess}
\exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
{\cs:w #1 Es\cs_end:}{\@@_specific:n{#2}}{\excess}
%^^A TODO: make super- or subscripted partial molar quantities work
% Excess partial molar property
\exp_after:wN \NewDocumentCommand \exp_after:wN
{\cs:w #1Epm\cs_end:}{}{\partialmolar{#2}
\c_math_superscript_token\excess}
}
\NewDocumentCommand{\NewResidualProperty}{m m}
{
\exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
{\cs:w #1 Rt\cs_end:}{\@@_extensive:n{#2}}{\residual}
\exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
{\cs:w #1 R\cs_end:}{\@@_intensive:n{#2}}{\residual}
\exp_after:wN \NewSuperscriptedSymbol \exp_after:wN
{\cs:w #1 Rs\cs_end:}{\@@_specific:n{#2}}{\residual}
% Residual partial molar property
\exp_after:wN \NewDocumentCommand \exp_after:wN
{\cs:w #1Rpm\cs_end:}{}{\partialmolar{#2}
\c_math_superscript_token\residual}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Nt,\Et,\Em,\Es,\Epm}
% \penalty-600%
% We define \cs{Nt} as the number of moles, as that changes between books a
% lot, but it does not have extensive, molar, and specific equivalents.
% Heat and work are defined, but lack partial molar properties. Area does not
% have excess or residual properties.
% \begin{macrocode}
\NewDocumentCommand{\Nt}{}{\g_@@_mole_symbol}
\NewThermodynamicProperty{E}{\g_@@_total_energy_symbol}
\NewThermodynamicProperty{U}{\g_@@_internal_energy_symbol}
\NewThermodynamicProperty{F}{\g_@@_Helmholtz_symbol}
\NewThermodynamicProperty{G}{\g_@@_Gibbs_symbol}
\NewThermodynamicProperty{H}{\g_@@_enthalpy_symbol}
\NewThermodynamicProperty{L}{\g_@@_Landau_symbol}
\NewThermodynamicProperty{V}{\g_@@_volume_symbol}
\NewThermodynamicProperty{S}{\g_@@_entropy_symbol}
\NewExtensiveProperty{A}{\g_@@_area_symbol}
\NewPartialMolarProperty{A}{\g_@@_area_symbol}
\NewExtensiveProperty{Q}{\g_@@_heat_symbol}
\NewExtensiveProperty{W}{\g_@@_work_symbol}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cVpm,\cPpm}
% Partial molar heat capacities are \emph{hard}, but the following
% implementation seems to work flawlessly\dots so far.
% \begin{macrocode}
\NewDocumentCommand{\cPpm}{}
{
\cs_set:Npn \@@_pm_case_one ##1
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
{\g_@@_pressure_symbol,##1}}
}
\cs_set:Npn \@@_pm_case_two [##1]##2
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_superscript_token{##1}
\c_math_subscript_token{\g_@@_pressure_symbol,##2}}
}
\cs_set:Npn \@@_pm_case_three_part_two ##1
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{\l_@@_pm_arg_tl}
\c_math_subscript_token{\g_@@_pressure_symbol,##1}}
}
\cs_set:Npn \@@_pm_case_four ##1
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{##1}\c_math_subscript_token
{\g_@@_pressure_symbol,\l_@@_pm_arg_tl}}
}
\cs_set:Npn \@@_pm_case_five
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
{\g_@@_pressure_symbol,\l_@@_pm_arg_tl}}
}
\partialmolar{\heatcapacitysymbol}
}
\NewDocumentCommand{\cVpm}{}
{
\cs_set:Npn \@@_pm_case_one ##1
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
{\g_@@_volume_symbol,##1}}
}
\cs_set:Npn \@@_pm_case_two [##1]##2
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{##1}\c_math_subscript_token
{\g_@@_volume_symbol,##2}}
}
\cs_set:Npn \@@_pm_case_three_part_two ##1
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{\l_@@_pm_arg_tl}
\c_math_subscript_token{\g_@@_volume_symbol,##1}}
}
\cs_set:Npn \@@_pm_case_four ##1
{
\@@_overline:n {\l_@@_pm_symbol_tl
\c_math_superscript_token{##1}
\c_math_subscript_token
{\g_@@_volume_symbol,\l_@@_pm_arg_tl}}
}
\cs_set:Npn \@@_pm_case_five
{
\@@_overline:n {\l_@@_pm_symbol_tl\c_math_subscript_token
{\g_@@_volume_symbol,\l_@@_pm_arg_tl}}
}
\partialmolar{\heatcapacitysymbol}
}
% \end{macrocode}
% \end{macro}
%
% \subsection{Residual and Excess Properties}
% \begin{macro}{\residual,\excess}
% Macros are defined for residual properties (departure from ideal gases)
% and excess properties (departure from ideal solutions). We begin with two
% macros to use for defining generic residual and excess properties that are
% not already defined.
% \begin{macrocode}
\NewDocumentCommand{\residual}{}{R}
\NewDocumentCommand{\excess}{}{E}
% \end{macrocode}
% \end{macro}
%
% \pagebreak[1]%
% \begin{macro}{\prodall,\sumall,\summallbutlast}
% The \cs{sumall} command and its cousin, \cs{sumallbutlast}, simplify the
% typesetting of commonly-used sums; the command \cs{prodall} does the same
% thing for products, viz.,
% \begin{verbatim}
% \[ \sumall_i x_i = 1 \qquad \sumallbutlast_i x_i = 1 - x_\ncomponents
% \qquad K = \exp\left(\frac{-\Deltarxn\Gm^\std}{RT}\right)
% = \prodall_i a_i^{\nu_i} \]
%\end{verbatim}
% gives
% \[ \sum_{i=1}^C x_i = 1 \qquad \sum_{i=1}^{C-1} x_i = 1 - x_C \qquad
% K = \exp\left(\frac{-\Delta G_\text{rxn}^\circ}{RT}\right)
% = \prod_{i=1}^C a_i^{\nu_i} \]
% \begin{macrocode}
\NewDocumentCommand{\sumall}{m m}
{ \sum\c_math_subscript_token{#2=1}
\c_math_superscript_token{\ncomponents} }
\NewDocumentCommand{\sumallbutlast}{m m}
{ \sum\c_math_subscript_token{#2=1}
\c_math_superscript_token{\ncomponents-1} }
\NewDocumentCommand{\prodall}{m m}
{ \prod\c_math_subscript_token{#2=1}
\c_math_superscript_token{\ncomponents} }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\IG,\IGM,\IS}
% The \cs{IG}, \cs{IGM}, and \cs{IS} macros (meaning ``ideal gas,'' ``ideal
% gas mixture,'' and ``ideal solution,'' respectively) should be used to
% make clean transitions between textbooks---some use ``IM'' or ``ID'' rather
% than ``IS,'' for example.
% \begin{macrocode}
\NewDocumentCommand{\IG}{}{{\text{IG}}}
\NewDocumentCommand{\IGM}{}{{\text{IGM}}}
\NewDocumentCommand{\IS}{}{{\text{IS}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Henryrat,\Henrymol}
% The Henry's Law constants for the rational basis ($y_i P = x_i h_i$) and
% the molal basis ($y_i P = C_i \mathcal{H}_i$) are given by the macros
% \cs{Henryrat} and \cs{Henrymol}, respectively. Using them this way
% consistently allows for easy switching back and forth.
% \begin{macrocode}
\NewDocumentCommand{\Henryrat}{}{h}
\NewDocumentCommand{\Henrymol}{}{\mathcal{H}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\gammarat,\gammamol}
% The ordinary activity coefficient is universally denoted $\gamma$, so I
% have not defined a special macro for that. However, symbols for the Henry's
% Law activity coefficients are far from universal, so I have defined macros to
% make their use consistent. The defaults render \cs{gammarat} as $\gamma^\ast$
% and \cs{gammamol} as $\gamma^\square$.
% \cs{gammamol} will use \cs{square} from packages if it is defined; if not,
% it ``fakes it'' with the definition below.
%^^A Backup for \square adapted from amsthm.sty with tweaks to make it
%^^A look reasonably similar to that from newpx (i.e., smaller than the
%^^A amsfonts) version
% \begin{macrocode}
\AtBeginDocument{%
\providecommand*{\square}{%
\text{\leavevmode
\hbox to.65em{%
\hfil\vrule
\vbox to.53em{\hrule width.45em\vfil\hrule}%
\vrule\hfil}%
}%
}%
}
\NewDocumentCommand{\gammarat}{}{\gamma\c_math_superscript_token\ast}
\NewDocumentCommand{\gammamol}{}{\gamma\c_math_superscript_token\square}
% \end{macrocode}
% \end{macro}
% \begin{environment}{thermovmatrix}
% This is a non-user-interface wrapper environment used to detect, in
% effect, whether \pkg{amsmath} has been loaded. If so, it uses its
% \env{vmatrix} environment for Jacobians; if not, it fakes it with
% \env{array} (which does not look nearly as good).
% \begin{macrocode}
\NewDocumentEnvironment{thermovmatrix}{}
{ \cs_if_exist:NTF \vmatrix
{ \begin{vmatrix} }
{ \left|\begin{array}{c c c c c c c c c c} }
}
{ \cs_if_exist:NTF \endvmatrix
{ \end{vmatrix} }
{ \end{array}\right| }
}
% \end{macrocode}
% \end{environment}
% \begin{macro}{Jacobian}
% The \cs{Jacobian} command typesets the Leibnitz notation for the Jacobian
% determinant.
% \changes{v2.00}{2023/11/16}{Reimplemented \cs{Jacobian} to handle an
% arbitary number of variables and implemented \cs{Jacobiandet} to
% handle the matrix representation of the Jacobian.}
% \begin{macrocode}
\NewDocumentCommand{\Jacobian}{m m}
{\@@_frac:nn{\partial(#1)}{\partial{(#2)}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{Jacobiandet}
% Similarly, the \cs{Jacobiandet} macro typesets the actual determinant that
% the Jacobian notation represents.
% \begin{macrocode}
\NewDocumentCommand{\Jacobiandet}{O{} O{} m m}
{
\@@_Jacobian_set_ncomponents:nn {#3} {#4}
\begin{thermovmatrix}
\@@_Jacobianmatrix:nnnn {#1} {#2} {#3} {#4}
\end{thermovmatrix}
}
\seq_new:N \l_@@_row_seq
\seq_new:N \l_@@_matrix_seq
\clist_new:N \l_@@_other_vars_clist
\clist_new:N \l_@@_other_vars_copy_clist
\tl_new:N \l_@@_Jacobian_x_tl
\tl_new:N \l_@@_Jacobian_n_tl
\tl_new:N \l_@@_Jacobian_temp_tl
\bool_new:N \l_@@_found_dots_bool
\cs_new:Nn \@@_Jacobian_set_ncomponents:nn
{
% If any entry is \dots, we assume the Jacobian is of the form
% d(f_1,\dots,f_n)/d(x_1,\dots,x_n) where f is some function
% (any symbol) and x is some variable (any symbol).
\tl_if_in:nnTF {#1} {\dots}
{% Has dots
\bool_set_true:N \l_@@_found_dots_bool
% look for what "x" is
\tl_set:Nn \l_@@_Jacobian_x_tl {\tl_head:n {#2}}
% look for what "n" is and set \ncomponents to it
\tl_set:Nx \l_@@_Jacobian_n_tl {\tl_item:nn {#2} {-1}}
\RenewExpandableDocumentCommand{\ncomponents}{}{\l_@@_Jacobian_n_tl}
}
{% Does not have dots; proceed accordingly
\bool_set_false:N \l_@@_found_dots_bool
}
}
\cs_new_protected:Nn \@@_Jacobianmatrix:nnnn
{
\seq_clear:N \l_@@_matrix_seq
\clist_set:Nn \l_@@_other_vars_clist {#4}
\clist_set_eq:NN \l_@@_other_vars_copy_clist \l_@@_other_vars_clist
\clist_map_inline:nn {#3}
{
\seq_clear:N \l_@@_row_seq
\tl_if_in:nnTF {##1} {\dots}
{% The current row has "dots" => row is \vdots && \vdots
\seq_put_right:Nn \l_@@_matrix_seq
{ \vdots \c_alignment_token \c_alignment_token \vdots }
}
{% Ordinary row
\clist_map_inline:nn {#4}
{
\tl_if_in:nnTF {####1} {\dots}
{% this column has "dots" in it
\seq_put_right:Nn \l_@@_row_seq \dots
}
{% Normal column
\clist_set_eq:NN \l_@@_other_vars_clist
\l_@@_other_vars_copy_clist
\clist_remove_all:Nn \l_@@_other_vars_clist {####1}
\bool_if:NTF \l_@@_found_dots_bool
{ \tl_set:Nn \l_@@_Jacobian_temp_tl {\tl_item:nn {####1} {-1}}
\seq_put_right:Nx \l_@@_row_seq
{
#1\Partial{##1}{####1}
{\allbut{\l_@@_Jacobian_temp_tl}{\l_@@_Jacobian_x_tl}}
}
}
{ \seq_put_right:Nx \l_@@_row_seq
{
#1\Partial{##1}{####1}
{\clist_use:Nn \l_@@_other_vars_clist ,}
}
}
}
}
\seq_put_right:Nx \l_@@_matrix_seq
{
\seq_use:Nn \l_@@_row_seq { \c_alignment_token }
}
}
}
\tl_if_empty:nTF {#2}
{
\tl_if_eq:nnTF {#1} {\displaystyle}
{ \seq_use:Nn \l_@@_matrix_seq { \\[2.75ex] } }
{ \seq_use:Nn \l_@@_matrix_seq { \\[1.25ex] } }
}
{
\seq_use:Nn \l_@@_matrix_seq { \\[#2] }
}
}
% \end{macrocode}
% \end{macro}
%^^X\end{implementation}
%
% \Finale
% \iffalse
%</package>
%<*example>
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{thermodynamics}
\title{Examples to Accompany the \textsf{thermodynamics} Package}
\author{Karl D. Hammond}
\date{}
\begin{document}
\NewThermodynamicProperty{B}{B}
\maketitle\noindent
The combined laws:
\begin{align*}
d\Et &= d\Ut + d\left(\frac12 m v^2\right) - d(m\phi) \\
d\Ut &= \dbar\Qt + \dbar\Wt + \Um d\Nt
= \dbar\Qt - P d\Vt + \Hm d\Nt
\\ &= \Partial*{\Ut}{\St}{\Vt,\allNs} d\St
+ \Partial*{\Ut}{\Vt}{\St,\allNs} d\Vt
+ \sumall_i \Partial*{\Ut}{\Nt_i}{\Vt,\St,\allNsbut{i}} d\Nt_i
\\ &= T d\St - P d\Vt + \sumall_i \mu_i d\Nt_i
\end{align*}
With surfaces present:
\begin{gather*}
d\Ut = T d\St - P d\Vt + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
d\Ht = T d\St + \Vt dP + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
d\Ft = -\St dT - P d\Vt + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
d\Gt = -\St dT + \Vt dP + \sigma d\At + \sumall_i \mu_i d\Nt_i \\
d\Lt = -\St dT - P d\Vt + \sigma d\At - \sumall_i \Nt_i d\mu_i \\
\Bt = \Ut + P\Vt - T\St - \sigma\At \\
d\Bt = -\St dT + \Vt dP - \At d\sigma + \sumall_i \mu_i d\Nt_i \\
\mu_i = \Bpm_i = \Gpm_i + \sigma \Apm_i
\end{gather*}
Some Maxwell reciprocity relations:
\begin{gather*}
\Partial*{\Vt}{T}{P,\allNs}
= \PartialMixSecond*{\Gt}{T}{P}{\allNs}
= \PartialMixSecond*{\Gt}{P}{T}{\allNs}
= -\Partial{\St}{P}{T,\allNs}
\\
\Partial*{\Gpm_i}{T}{P,\allXs}
= \PartialMixSecond*{\Gt}{T}{\Nt_i}{P,\allNsbut{i}}
= \PartialMixSecond*{\Gt}{\Nt_i}{T}{P,\allNsbut{i}}
= -\Partial*{\St}{\Nt_i}{T,P,\allNsbut{i}}
= -\Spm_i
\end{gather*}
Temporary changes of derivative delimiters:
\begin{gather*}
\begin{thermobrackets}
\Partial*{\Vt}{T}{P,\allNs}
\end{thermobrackets}
\begin{thermobar}
= \PartialMixSecond*{\Gt}{T}{P}{\allNs}
\end{thermobar}
\begin{thermomolesrange}
= \PartialMixSecond*{\Gt}{P}{T}{\allNs}
\end{thermomolesrange}
\begin{thermobraces}
= -\Partial*{\St}{P}{T,\allNs}
\begin{thermoNOsubscripts}
\begin{thermomolesrange}
= -\Partial{\St}{P}{T,\allNs}
\end{thermomolesrange}
\end{thermoNOsubscripts}
\end{thermobraces}
\end{gather*}
Inline derivatives:
\begin{gather*}
\mu_i = \Partialinline{\Gt}{\Nt_i}{T,P,\allNsbut{i}}
= \Partialinline{\Ft}{\Nt_i}{T,\Vt,\allNsbut{i}}
= \Partialinline{\Ht}{\Nt_i}{\St,P,\allNsbut{i}}
= \Partialinline{\Ut}{\Nt_i}{\St,\Vt,\allNsbut{i}}
\end{gather*}
The heat capacities:
\begin{gather*}
\cV = T \Partial*{\Sm}{T}{\Vm,\allXs} = \Partial*{\Um}{T}{\Vm,\allXs}
= -T\PartialSecond{\Fm}{T}{\Vm,\allXs}
\\
\cP^\IGM = T \Partial*{\Sm^\IGM}{T}{P,\allYs}
= \Partial*{\Hm^\IGM}{T}{P,\allYs}
\begin{thermobrackets}
= -T\PartialSecond{\Gm^\IGM}{T}{P,\allYs}
\end{thermobrackets}
\\
\cVt = T \Partial*{\St}{T}{\Vt,\allNs} = \Partial*{\Ut}{T}{\Vt,\allNs}
\begin{thermobraces}
= -T\PartialSecond{\Ft}{T}{\Vm,\allNs}
\end{thermobraces}
\\
\begin{thermobar}
\cPt = T \Partial*{\St}{T}{P,\allNs} = \Partial*{\Ht}{T}{P,\allNs}
= -T\PartialSecond{\Gt}{T}{P,\allNs}
\end{thermobar}
\\
\cVs = T \Partial*{\Ss}{T}{\Vs,\allWs} = \Partial*{\Us}{T}{\Vs,\allWs}
\begin{thermoplain}
= -T\PartialSecond{\Fs}{T}{\Vs,\allWs}
\end{thermoplain}
\\
\cPs = T \Partialbigg*{\Ss}{T}{P,\allWs} = \Partialbigg*{\Hs}{T}{P,\allWs}
= -T\PartialSecondbigg{\Gs}{T}{P,\allWs}
\\
\begin{split}
\cPpm_i &= \Partial*{\cPt}{\Nt_i}{T,P,\allNsbut{i}}
= T \PartialMixSecond*{\St}{\Nt_i}{T}{P,\allNsbut{i}}
= T \PartialMixSecond*{\St}{T}{\Nt_i}{P,\allNsbut{i}}
\\ &= T \Partial*{\Spm_i}{T}{P,\allXs}
= \Partial*{\Hpm_i}{T}{P,\allXs}
= \PartialMixSecond*{\Ht}{T}{\Nt_i}{P,\allNsbut{i}}
= \PartialMixSecond*{\Ht}{\Nt_i}{T}{P,\allNsbut{i}}
\\ &= -T\PartialSecond*{\Gpm_i}{T}{P,\allXs}
= -T\Partial{{}^3 \Gt}{T^2\partial \Nt_i}{P,\allNsbut{i}}
\end{split}
\end{gather*}
Other measurable quantities:
\begin{align*}
\alphaS &= \frac{1}{\Vm} \Partial{\Vm}{T}{\Sm} &
\alphaP &= \frac{1}{\Vm} \Partial{\Vm}{T}{P} \\
\kappaS &= -\frac{1}{\Vm} \Partial{\Vm}{P}{\Sm} &
\kappaT &= -\frac{1}{\Vm} \Partial{\Vm}{P}{T}
\end{align*}
The chemical potential, fugacity, and activity:
\[ \mu_i = \Gpm_i = \Gm_i^\std + RT \ln a_i
= \Gm_i^\std + RT\ln\left(\frac{\fmix_i}{\fstd_i}\right) \]
Equilibrium in a chemical reaction:
\[ \sumall_i \nu_i \mu_i = 0
\Rightarrow
\exp\left(\frac{-\Delta\Gm^\std}{RT}\right) = K = \prodall_i a_i^{\nu_i} \]
Partial molar quantities:
\begin{align*}
\Hpm{i} &= \Partial*{\Ht}{\Nt_i}{T,P,\allNsbut{i}}
= \Hm + \Nt \Partial*{\Hm}{\Nt_i}{T,P,\allNsbut{i}}
\\ &= \Hm + \Partial*{\Hm}{x_i}{T,P,\allXsbut{i}}
- \sumallbutlast_j x_j \Partial*{\Hm}{x_j}{T,P,\allXsbut{j}}
= \Partial*{\Hm}{x_i}{T,P,\allXsbut{i}} + \Hpm_\ncomponents
\end{align*}
\[ \Vpm_i = \Partial{\Vt}{\Nt_i}{T,P,\allNsbut{i}} \]
Fugacity and related properties:
\begin{gather*}
\Gpm_i = \mu_i
= \Gm_i^\std(T) + RT\ln a_i
= \Gm_i^\std(T) + RT\ln\left(\frac{\fmix_i}{\fstd_i}\right)
\\
a_i = \frac{\fmix_i}{\fstd_i}
= x_i \gamma_i
\exp\left(\frac{1}{RT} \int_{\Pstd}^P \Vm_i(T,p)\,dp\right)
\approx x_i \gamma_i
\\
\begin{split}
\fmix_i &= x_i \phimix_i P
= x_i \gamma_i \fpure_i = x_i \gamma_i \phipure_i P
= x_i \gammarat_i \Henryrat_i
= C_i \gammamol_i \Henrymol_i
= x_i \gamma_i \fsat_i
\exp\left(\frac{1}{RT} \int_{\Psat_i}^P \Vm_i(T,p)\,dp\right)
\\ &= x_i \gamma_i \Psat_i \phisat_i
\exp\left(\frac{1}{RT} \int_{\Psat_i}^P \Vm_i(T,p)\,dp\right)
\approx x_i \gamma_i \Psat_i
\end{split}
\end{gather*}
Chemical Equilibria:
\begin{gather*}
\Deltarxn\Hm^\std = \sumall_i \nu_i \Deltaf\Hm_i^\std \\
\Deltarxn\Gm^\std = \sumall_i \nu_i \Deltaf\Gm_i^\std
= \sumall_i \nu_i \mu_i^\std \\
\Deltarxn\cP^\std = \sumall_i \nu_i \cP_i^\std \\
\mu_i = \mu_i^\std + RT\ln a_i \\
a_i = \begin{cases}
\displaystyle
\frac{y_i \phimix_i P}{\Pstd} \approx \frac{y_i P}{\Pstd}
& \text{(gases)} \\
\rule{0pt}{5ex}%
\displaystyle
x_i \gamma_i \exp\left(\frac{1}{RT} \int_{\Pstd}^P \Vm_i(T,p)\,dp\right)
\approx
x_i \gamma_i \exp\left(\frac{\Vm_i(P-\Pstd)}{RT}\right)
\approx x_i \gamma_i \approx 1
& \text{(solids, solvents)} \\
\displaystyle
\rule{0pt}{5ex}%
\frac{C_i \gammamol_i}{C_i^\std}
\exp\left(\frac{1}{RT}
\int_{\Pstd}^P \Vpm_i^\infty(T,p,\allXs)\,dp\right)
\approx
\frac{C_i \gammamol_i}{C_i^\std} \approx \frac{C_i}{C_i^\std}
& \text{(solutes)}
\end{cases}
\end{gather*}
Phase change properties:
\begin{gather*}
\Deltafus\Sm = \Sm^L - \Sm^S \\
\Deltasub\Vm = \Vm^V - \Vm^S \\
\Deltavap\Gm = \Gm^V - \Gm^L
\end{gather*}
Specific properties:
\newcommand*{\Btilde}[2][]{\widetilde{B}_{#2}^{#1}}
\[ \Btilde{j} \equiv \Partial{\Bt}{m_j}{T,\Vs,\allMsbut[i]{j}} \]
and thus
\[ \Btilde{i}
= \frac{\Bpm{i}}{M_i}
+ \Biggl(\Vs - \frac{\Vpm_i}{M_i}\Biggr)
\Partial*{\Bs}{\Vs}{T,\allMs}
= \frac{\Bpm{i}}{M_i}
+ \Biggl(\Vs - \frac{\Vpm_i}{M_i}\Biggr)
\Partial{\Bs}{\Vs}{T,m,\allWs} \]
and
\[ \Bs = \sumall_i w_i \Btilde{i}. \]
Excess and Residual (Departure) Properties:
\begin{align*}
\HR &= \Hm - \Hm^\IG &
\FR &= \Fm - \Fm^\IGM \\
\SE &= \Sm - \Sm^\IS &
\VRpm_k &= \Vpm_k - \Vpm_k^\IGM
\end{align*}
Jacobians:
\begin{gather*}
\Jacobian{\St,\Vt}{T,P} = \Jacobiandet{\St,\Vt}{T,P} \\
\Jacobian{f,g,h}{x,y,z} = \Jacobiandet[\displaystyle]{f,g,h}{x,y,z} \\
\Jacobian{h_1,\dots,h_k}{z_1,\dots,z_k} =
\Jacobiandet{h_1,\dots,h_k}{z_1,\dots,z_k} \\
\cP = T\Partial{\Sm}{T}{P}
= T\Jacobian{\Sm,P}{T,P}
= -T\Jacobian{\Sm,P}{T,\Vm} \Jacobian{T,\Vm}{T,P}
= -T\Jacobian{P,\Sm}{\Vm,\Sm} \Jacobian{\Vm,\Sm}{T,\Vm}
\Jacobian{T,\Vm}{T,P}
= \gamma \cV
\end{gather*}
\end{document}
%</example>
% \fi
%
% \Finale
\endinput
|