<<

Numerical Simulations of the Molecular Behavior and Entropy of Non-Ideal

Matthew David Marko∗ Orcid ID: 0000-0002-6775-7636 Marko Motors LLC, Seaside Heights NJ 08751 USA (Dated: October 19, 2020) A numerical model is built, simulating the principles of kinetic gas theory, to predict pressures of molecules in a spherical pressure vessel; the model tracks a single particle and multiplies the force on the spherical walls by a mole of molecules to predict the net pressure. An intermolecular attractive force is added for high-density simulations, to replicate a real fluid; the force is chosen to ensure the fluid matches the Peng-Robinson as it is compressed to a near supercritical density. The standard deviations of the molecule position and velocity with respect to temperature and density is studied to define the entropy. A parametric study of a Stirling cycle heat engine utilizing near-supercritical densities is modeled, to study how the temperature dependence of the attractive intermolecular Van der Waal forces can affect the net total entropy change to the surrounding environment. Email: [email protected]

I. INTRODUCTION though exceptions to equation 5 have been observed at the quantum level [13–15] as well as in the presence of In the design of any thermodynamic system to convert supercritical fluids [16]. heat to and from mechanical work, the laws of thermo- Entropy is also defined as a level of disorder, charac- dynamics must always be considered. The first law of terized by Boltzmann’s entropy equation [2–5] thermodynamics states that the change in internal en- S = k ·log(Ω), (6) ergy equals the heat and work input into the working B fluid [1–6] where S (J/K) represents the total entropy, kB (1.38065·10−23 J/K) represents Boltzmann’s constant, δu = δq − δw, (1) log represents the natural logarithm, and Ω represents the number of possible microstates of the system of where δu (J/kg) is the change in specific internal energy, molecules. If the molecules are at absolute zero (T = δq (J/kg) is the specific heat transfered, and w (J/kg) is 0 K), when there is no movement of the molecules, then the specific work applied across the boundary [2–6] Ω=1, and thus (according to equation 6) S=0 J/K. δw = P ·δv. (2) Equation 6 can be derived from the equation for isothermal (δT =0) heating and expansion of an ideal gas. The second law has been described by Rudolph Clausius An ideal gas is a fluid at a low enough density where [1] in 1854 as the intermolecular attractive and repulsive Van der Waal forces are negligible, and therefore the equation of state I δq ≤ 0, (3) is defined in equation 7 T P ·V = N·kB·T, (7) which states that any internally reversible thermody- 3 namic cycle must generate a positive entropy δs≥0 to where P (Pa) represents the pressure, V (m ) represents the surrounding universe, where the change in entropy the total volume of the gas, N represents the number δs (J/kg·K) is defined as [2–12] of molecules of the gas, kB is the Boltzmann constant (1.38065·10−23 J/K), and T (K) represents the absolute δq temperature. When an ideal gas is undergoing isothermal δs = , (4) T expansion [3], the heat input qδT =0 (J/kg) is equal to the work output WδT =0 (J/kg) defined by equation 2, and where T (K) is the absolute temperature, and δq (J/kg) therefore the heat input and work output of an ideal gas represent the heat transfered per unit mass. Because of arXiv:2004.03584v2 [cond-mat.stat-mech] 15 Oct 2020 undergoing isothermal heating and expansion is defined Clausius’ equation, an ideal gas heat engine has a ther- in equation 8 modynamic efficiency limit of the Carnot efficiency Z Z dV wout qin − qout TL qδT =0 = WδT =0 = P ·dV = N·kB·T · , (8) ηC = = = 1 − , (5) V qin qin TH V2 = N·kB·T ·log( ). V1 The change in entropy of an ideal gas is defined by equa- ∗ [email protected] tion 4, and therefore the change in entropy of an ideal 2 gas undergoing isothermal expansion is found by plug- and thus equation 13 can be rewritten as ging equation 8 into equation 4 2 N·mm·vRMS δq V2 V2 N F = . (15) δsδT =0 = = N·kB·log( ) = kB·log( ) . (9) 3·L T V1 V1 By doubling the volume, you are effectively doubling the In the kinetic theory, equation 15 would only apply to number of microstates possible (for each molecule), and molecules that have no rotational or vibrational energies, therefore one can derive equation 6 from 9. specifically monatomic molecules such as , neon, argon, xenon, , or radon gas [4]. The pressure, by definition, is merely the ratio of the II. KINETIC THEORY OF AN IDEAL GAS total force over the area of the container, and therefore assuming the container is cubic in shape, the pressure P The kinetic model of an ideal gas [3, 4, 17] is a well- (Pa) is established model to predict the kinetic energy of an ideal 2 2 F N·mm·vRMS N·mm·vRMS gas. Internal energy, by definition, is the summation of P = 2 = 3 = , (16) the kinetic energy from all of the random molecular mo- L 3·L 3·V tion within a fluid, as well as any potential energy from where V (m3) is the volume of the container. intermolecular forces. In the kinetic model, the gas is The total kinetic energy of the gas KE (J) is defined assumed to follow the ideal gas equation of state defined as the sum of the kinetic energies of the gas molecules in equation 7. For the kinetic model to be applicable, the 1 gas must be ideal, where all of the molecules are moving KE = ·N·m ·v2 , (17) independent of each other, and there is no interaction 2 m RMS between different gas molecules, either by collision or in- and therefore plugging equation 17 into equation 16 termolecular forces [4]. If a molecules is moving within the x direction and hits 2·KE P = , the boundary of a container or pressure vessel, provided 3·V the gas is thermodynamically stable and there is no heat transfer, it will bounce off of the wall in the opposite and therefore the kinetic energy of a monatomic ideal gas direction. The change in momentum for each molecular can be defined as collision is therefore 3 KE = ·P ·V. (18) ∆p = (mm·vx) − (−mm·vx) = 2·mm·vx, (10) 2 where ∆p (kg·m/s) is the change in momentum, mm (kg) As the kinetic model is dealing with an ideal gas, equation is the mass of an individual molecule, and vx is the ve- 7 is applicable, and thus [4] locity in the x-direction. The average time ∆τ (s) for a molecule to cross the length L (m) of the pressure vessel 3 3 3 KE = ·P ·V = ·mT ·R·T = ·N·kB·T, (19) is 2 2 2 2·L ∆τ = . (11) where mT (kg) is the total mass of the gas vx m = N·m . The force applied to the walls of the pressure vessel with T m an individual molecular collision Fm (Newtons) is the The relationship between temperature and kinetic energy change in momentum per unit time is thus defined with equations 17 and 19. This can be 2 ∆p mm·vx rewritten as Fm = = , (12) ∆τ L 1 3 KE = ·N·m ·v2 = ·N·k ·T, and the total force on the walls of the pressure vessel F 2 m RMS 2 B (Newtons) is thus and thus the average total velocity of a particle of an ideal N·m ·v2 F = N·F = m x , (13) gas is proportional to the square root of the temperature m L [4] where N is the total count of the molecules. r So far this analysis has only been in the x-direction, 3·kB·T vRMS = . (20) when in reality the molecules are bouncing in three di- mm mensions. Assuming the average speed in all three di- rections are identical, as is the case in a stable fluid, ac- The kinetic heat energy δq of a monatomic ideal gas is cording to Pythagorean theorem the average Root Mean simply Square (RMS) total velocity v (m/s) is thus RMS 3 Z T 3 2 2 2 2 2 U = ·N·kB· dT = ·N·kB·T. vRMS = vx + vy + vz = 3·vx, (14) 2 0 2 3

The change in entropy of an ideal monatomic gas under- a NY ·1 vector-array, ranging from 0.2 to 1.8, averaging going isochoric heating at a constant volume is therefore 1.0, with a standard deviation of 0.71. This vector-array will be multiplied by the average molecule velocity at 3 Z T dT 3 T δs = ·N·k = ·N·k ·log( ) the boundary vavg; the RMS of the velocity vector-array δV =0 2 B T 2 B T T0 0 will be equal to vRMS determined with 20. Within this 2 simulation, a value of N of 100 is used. 3 mm·vRMS/(3·kB) Y = ·N·kB·log( 2 ) The time-step δτ (s) is determined by the estimated 2 mm·v /(3·kB) RMS,0 time for an argon molecule traveling at the average speed 3 vRMS 2 = ·N·kB·log( ) vavg (m/s) across the diameter of the sphere 2·Rsphere 2 vRMS,0 (m). This time is divided by the integer value Nδτ that vRMS is specified by the model, to give a time-step. = 3·N·kB·log( ) (21) vRMS,0 2·Rsphere 1 This represents the change in entropy for heating an ideal δτ = ( )· (25) vavg Nδτ gas at a constant volume; it is different from equation 9, which represents the isothermal heating of an ideal It is necessary to record the molecule’s position and ve- gas with simultaneous expansion in order to maintain a locity with each increment, but with different angles and constant temperature. If equation 9 and 21 are combined, speeds, it is impossible to know exactly how many time the estimated entropy is steps will be needed for each test parameter. In this Fortran code, an array length of 10·N was found to V δτ S = N·k ·{3·log(v ) + log( )}. (22) be more than enough to avoid any risk of running out B RMS b·MM of array space. In this study, a resolution of Nδτ =300 was used; increasing the resolution beyond this number III. KINETIC GAS SIMULATION was not observed to have any significant impact on the results. A model was build in the Fortran programming lan- At each velocity increment, the model simulates a guage, to simulate one mole (6.02214086·1023) of argon molecule leaving the surface of the sphere at different molecules traveling in a spherical volume. Argon was angles. As a sphere is effectively identical at all surface chosen because it is a simple monatomic molecule, com- locations, the point of initial contact will be defined as monly used in industry, and its critical properties are not (-R,0,0). The initial velocity will be defined in three di- at excessively low temperatures (ex. Helium). Argon has mensions as a molar mass MM of 39.9 g/mole, a critical pressure Pc Vx = Vi·sin(θ)·cos(φ) (26) of 4.863 MPa, a critical temperature Tc of 150.687 K, a critical density of 535 kg/m2, and a critical specific vol- Vy = Vi·sin(θ)·sin(φ) 3 ume Vc of 1.8692 cm /g. Vz = Vi·cos(θ), The model will take the dimensionless reduced tem- perature T and reduced specific volume V as inputs. where φ ranges from 0 to π/2, and θ ranges from 0 to R R π, both in 91 increments, resulting in 912=8,281 dif- The temperature is easily calculated as T = TR·Tc, and the volume (for one mole) is calculated as V = ferent directions. The velocity magnitude Vi (m/s) for sphere the individual increment is determined from the temper- VR·Vc·MM. From the known volume of the sphere, the radius and surface area are easily calculated as ature (equation 20), and NY =100; there is thus a total of 828,100 simulations for each temperature and volume 1 3 3 increment. R = ( ·V ) , (23) sphere π·4 sphere The kinetic gas theory assumes the molecule travels A = 4·π·R2 , across the long length of the volume and directly impacts sphere sphere the wall; in reality molecules will travel at all possible The model has the option of simulating the particle at angles. If a molecule were to travel directly through the a constant speed for a given temperature, if so the speed center of the sphere, the time τ (s) to travel will simply is constantly the vRMS speed for the given temperature be τ = 2·Rsphere/vavg, and the force due to the change defined in equation 20. The model also gives the option in momentum for a single molecule will be derived from 2 of simulating a profile of faster and slower speeds; the equation 15, where F = mm·vRMS/(3·2·Rsphere). As- speed profile will maintain the same RMS average speed suming the spherical volume, if a molecule were to travel defined in equation 20, and the average speed vavg (m/s) at an angle from the center of the sphere, the travel time will be determined as τ (s) will be reduced, but the force will also be reduced as the molecule is hitting the surface at an angle, and will r 8 vavg = vRMS· . (24) only transmit part of its energy to changing momentum 3·π and direction. If the model calls for NY velocity increments to be sim- The simulation starts off with a molecule at position ulated, a subroutine in the Fortran code will generate (-R,0,0). With each time-step, it increments the three 4 dimensions based on the 3-dimensional velocity described where ω is Pitzer’s acentric factor, defined as in equation 26. The model uses a while loop until the P radius r (m) of the position c ii ω = log10( 0 ) − 1, (31) PS p 2 2 2 rii = x + y + z , (27) 0 where PS (Pa) is the saturated pressure at a reduced tem- perature of T = 0.7, and P (Pa) is the critical pressure. exceeds the radius of the sphere, r > R . At this R c ii sphere For all of the monatomic fluids including argon, ω = 0. point, the molecule has impacted the cylinder wall. If The coefficient A represents the intermolecular attractive the molecule travels right through the center and im- force, and the coefficient B represents the actual volume pacts the other end at position (R,0,0), then the velocity of the molecules at absolute zero. As the specific volume will be V ·(1, 0, 0), and the force impacted will be at a i v (m3/kg) increases (and the density decreases), equation maximum; the travel time τ (s) will also be the maxi- 30 matches the ideal gas law defined in equation 7. mum τ = 2·R /V . If the molecule were to travel sphere i As the density of a fluid increases to the point of being at a 90◦ perpendicular direction, where the velocity were a saturated liquid, saturated gas, or supercritical fluid, V ·(0, 1, 0) or V ·(0, 0, 1), the position will remain at (- i i intermolecular attractive (and repulsive) forces [21–26] R,0,0) and the travel time τ will effectively be 0. For can impact the pressure and temperature of the fluid. all the molecules traveling at angles in between the two As the molecules get closer togetehr in the presence of extremes, the force applied is simply the dot product of attractive intermolecular forces, the internal potential the velocity with the position of the impact energy will decrease. The thermodynamic data yields VX = X ·V + X ·V + X ·V , (28) an empirical equation that closely predicts the change rat x x y y z z in specific internal energy ∆u (J/kg) during isothermal and the dimensionless VXrat is applied to the equation compression and expansion [16] for the force applied by a single molecule Fm (N) defined a0 1 1 in equation 29 ∆u = √ ·( − ), (32) T v1 v2 q 2 2.5 2 2 2 R ·T VXrat·mm· Vx + Vy + Vz 0 c a = 1 . Fm = . (29) 9·(2 3 − 1)·Pc 3·2·Rsphere 3 where v1 and v2 (m /kg) represent the specific volume, Throughout this simulation, for all initial angles and T represents the temperature, R (J/kg·K) represents the velocities, the position and velocity in three dimensions gas constant, is tabulated and recorded. Each position and velocity is stored in a large data file, and at the conclusion of the RU A·kB R = = , (33) simulation, the average, RMS, and standard deviation of MM MM both the positions and the velocities are determine. The where A is Avogadro’s Number 6.02214·1023, k is Boltz- purpose of determining the standard deviation is to find B man’s Constant 1.38·10−23 (J/K), MM (kg/mole) is the the relationship between the standard deviation of the molar mass, T (K) represents the critical temperature, position and velocity, as it relates to entropy, determined C and P (Pa) represents the critical pressure. The inter- with equations 4, 9, and 21. C molecular attractive parameter a’ defined in equation 32 is thus 1,063.8 Pa·K0.5·m6·kg−2 for argon. The value of a’ happens to be the same coefficient IV. KINETIC-POTENTIAL SIMULATION used in the Redlich-Kwong [18] equation of state; equa- tion 32 does not actually use any equation of state, as it is The ideal gas equation breaks down in the presence an empirical equation based on published data by NIST of intermolecular attractive and repulsive Van der Waal in the literature. The change in internal energy equa- forces, and therefore empirical equations of states are tion 32 during evaporation has been observed on many used, such as the Redlich-Kwong [18] and the Peng- different molecules, including the highly polar fluid wa- Robinson equation of state [19, 20] ter; the monatomic fluids of argon, krypton, and xenon; the diatomic fluid nitrogen; ; the hydrocarbons R·T A·α P = − , (30) of methane, ethane, propane, and both normal and iso- v − B v2 + 2·B·v − B2 butane; and the refrigerants Freon R-12, R-22, and R- R2·T 2 134a. All of the data provided utilized the available A = 0.45724· c , Pc online tables from NIST [27], which are based on pre- R·T viously published experimental and empirical thermody- B = 0.07780· c , P namics data [28–53]. First, equation 32 matched remark- c ably for the change in internal energy during isother- p 2 α = (1 + κ·(1 − TR)) , mal expansion during vaporization, all over a wide tem- κ = 0.37464 + 1.54226·ω − 0.26992·ω2, perature range ∆T (K). The calculated coefficient a’ 5

(Pa·K0.5·m6·kg−2), determined with the parameters in forces, these are not based in reality, and the repulsive Table I, and the coefficient of determination R2 between forces due to the Pauli Exclusion Principle are considered the NIST values and equation 32 are all tabulated in Ta- by subtracting the minimum possible volume B (m3/kg) ble II. in the VDW equation of state. For the sake of simplicity, assume that the volume is Fluid M (g/Mole) TC (K) PC (MPa) a perfect sphere of a real, monatomic fluid molecules fol- Water (H O) 18.02 647.14 22.064 2 lowing the VDW equation of state. The surface area Argon (Ar) 39.948 150.687 4.863 2 3 Krypton (Kr) 83.798 209.48 5.525 Asphere (m ) and volume of this sphere Vsphere (m ) is Xenon (Xe) 131.3 289 5.84 simply Nitrogen (N2) 28.0134 126.2 3.4 4 3 Ammonia (NH3) 17.0305 405.4 11.3119 Vsphere = ·π·Rsphere, (35) Methane (CH ) 16.043 190.53 4.598 3 4 2 Ethane (C2H6) 30.07 305.34 4.8714 Asphere = 4·π·Rsphere, Propane (C3H8) 44.098 369.85 4.2477 where Rsphere (m) represents the sphere radius. Next, Butane (C4H10) 58.125 425.16 3.796 assume a molecule is on the far edge of this sphere; Iso-Butane (C4H10) 58.125 407.85 3.64 Freon R-12 120.91 385.12 4.1361 to determine the net attractive forces one must deter- Freon R-22 86.47 369.295 4.99 mine the summation of the average distances of the other Freon R-134a 102.03 374.21 4.0593 molecules within the volume. A(x) TABLE I. The molar mass M (g/Mole), the critical temper- Pˆ(x) = . (36) ature TC (K), and the critical pressure PC (MPa) for various Aavg molecules. The cross-section area of the sphere at a given X -axis point A(x) can be found from the radius of the cross section Fluid a’ ∆T (K) R2 2 2 −1 x Water (H2O) 43,971 274-647 0.98572 A(x) = π·Rsphere·cos (sin ( )), (37) Argon (Ar) 1,062 84-150 0.98911 Rsphere Krypton (Kr) 484 116-209 0.98858 while the average cross section area is simply the total Xenon (Xe) 417 162-289 0.98972 volume of the sphere over the diameter of the sphere Nitrogen (N2) 1,982 64-126 0.98565 Ammonia (NH3) 29,824 196-405 0.98603 4 3 3 ·π·Rsphere Methane (CH4) 12,520 91-190 0.97818 Aavg = , (38) 2·Rsphere Ethane (C2H6) 10,937 91-305 0.94881 Propane (C3H8) 9,418 86-369 0.93372 2 2 = ·π·Rsphere , Butane (C4H10) 8,594 135-424 0.9631 3 Iso-Butane (C4H10) 8,078 114-407 0.95368 Freon R-12 1,423 175-384 0.98465 and now the probability Pˆ(x) can be found by plugging Freon R-22 2,077 172-369 0.98741 the results of equation 37 and 38 into equation 36 Freon R-134a 1,896 170-374 0.9884 3 x Pˆ(x) = ·cos2(sin−1( )). (39) TABLE II. The calculated coefficient a’ (Pa·K0.5·m6·kg−2), 2 Rsphere determined with the parameters in Table I, and the coefficient The next step is to integrate across the diameter of of determination R2 between the NIST values and equation 32, over a specified temperature range ∆T (K). the sphere along the X -axis in order to find the overall average distance to the sixth power δx¯6 (m) Z R If dealing with a purely ideal gas, molecules have no δx¯6 = (R − x)6·Pˆ(x)dx, (40) interaction with each other, and the pressure and veloc- −R ities can be solved with the purely analytical approach Z Rsphere 3 x = (R − x)6· ·cos2(sin−1( ))dx, of the kinetic gas theory. To model real fluids, with in- sphere 2 R termolecular Van der Waal fluids, assumptions for the −Rsphere sphere intermolecular forces are necessary. In Lennard Jones’ 16 6 = ·Rsphere . equation, the attractive VDW force FVDW (N) for two 3 molecules is proportional to the distance between parti- It is desired not just for the average distance to a particle cles to the sixth exponent [5, 54] at the edge of the sphere, but all throughout the radius. a0 A particle moving on the X -axis will experience attrac- F = , (34) VDW r6 tion from particles both in front of and behind it, and where a’ is a constant and r (m) is the distance between therefore the proper average δx¯6, for the purpose of de- two molecules. While the Lennard Jones potential equa- termining net total attraction towards the center of the tion [54] also includes a twelfth power for the repulsive sphere 6

Z r Z Rsphere ¯6 6 3 2 −1 x 6 3 2 −1 x δx (r) = (r − x) · ·cos (sin ( ))dx − (Rsphere − x) · ·cos (sin ( ))dx, (41) −Rsphere 2 Rsphere r 2 Rsphere which can be simplified by the approximate equation in time for the molecule to travel across the spherical volume. An increasing force will inherently accelerate 16 δx¯6(r)≈ ·r3, (42) the molecule towards the center, and decelerate it to- 3 wards the other side, reducing the travel time, and thus where r (m) represents the radial position on the X - increasing the pressure. It is necessary to select a force that balances these two impacts on the final pressure, in axis, where 0 < r < Rsphere. The correlation coefficient between the two equations 41 and 42, where δr=0.001, order to achieve the correct pressure for the equation of is R = 0.99936. state. A parametric study of the supercritical argon r δx¯6(r) δx¯6(r) molecules propagating in the sphere was conducted to eq. 41 eq. 42 determine the exact function for the intermolecular force 0.05005 0.033158 0.00066867 on each molecule. The maximum such a force will be 0.1001 0.06865 0.0053494 is that which will cause the drop in pressure observed 0.15015 0.10887 0.018054 in most empirical equations of states, such as the Peng- 0.2002 0.15633 0.042795 Robinson defined in equation 30 0.25025 0.21373 0.083584 0.3003 0.28399 0.14443 A·α 0.35035 0.37035 0.22935 δP = − 2 2 . (43) 0.4004 0.4764 0.34236 v + 2·B·v − B 0.45045 0.60615 0.48746 0.4995 0.76063 0.66467 The derivative of the change in internal energy defined 0.54955 0.95109 0.88515 in equation 32 gives a very close approximation for δP 0.5996 1.1803 1.1497 R2·T 2.5 1 1 0.64965 1.4545 1.4623 δP ≈ − c ·√ · . 0.6997 1.7809 1.827 1 2 9·(2 3 − 1)·Pc T v 0.74975 2.1671 2.2477 0.7998 2.6218 2.7286 The force needs to be some ratio of this, as increasing the 0.84985 3.1547 3.2736 force will increase the average speed of a molecule (for a 0.8999 3.7763 3.8867 given v (m/s) at the surfaces), reducing the time 0.94995 4.4982 4.5719 RMS 1 5.3333 5.3333 in between impacted the sphere’s surface, and increasing the pressure. TABLE III. Comparison of δx¯6(r) functions between equa- A parametric study was performed to find the exact tion 41 and 42. The correlation coefficient between the two ratio of this pressure, and a function for the force (N) equations (δr=0.001) is R = 0.99936. on a given molecule, accelerating it as it travels towards the center and decelerating it as it travels back towards the surface, was determined in order that the molecule While typical conservative forces such as gravity, elec- satisfy the Peng-Robinson equation of state defined in trostatic forces, and VDW attractive forces increase as equation 30. The Van der Waal attractive force FVDW the distance between two attractive objects decreases, it (N) is thus is clear from equation 41 that the forces will decrease R2·T 2.5 1 1 A when a given molecule moves closer to the center of the c √ sphere FVWD = χ· 1 · · 2 · , (44) volume, proportional to the radial position cubed. This 9·(2 3 − 1)·Pc T v N makes physical sense, as near the center of the sphere, the attractive forces of neighboring molecules on one side of where N is the number of molecules in the sphere (one the molecule counteract the attractive forces from the mole for this simulation), and χ is a dimensionless coef- other side. ficient When modeling the effects of intermolecular attractive 0.8441 forces, it is not enough to simply take the pressure re- χ = 2.3246 − √ − 0.8670·TR,TR≤1 (45) (VR) duced from the intermolecular attractive Van der Waal 0.8441 √ =2.3246 − √ − 0.8670· TR,TR≥1 force, multiply it by the spherical surface area, divide it (VR) by the number of molecules, and reduce it by the rela- tive radius cubed. The reason for this is that the overall determined from a parametric study. This force FVDW change in pressure of the real fluid includes the pressure (N) is the force at the surface of the sphere towards the reduced from the attractive force, as well as the change center; this force decreases in each of the three dimen- 7 sions as the molecule gets closer to the center x F = −F ·( )3. x VDW R y F = −F ·( )3. y VDW R z F = −F ·( )3. z VDW R

V. KINETIC SIMULATION TO DETERMINE ENTROPY

A parametric simulation of this model was conducted, with twenty temperature parameters and ten volume pa- rameters, all with one mole of argon held in a sphere, for a total of 200 independent simulations of 828,100 molec- ular simulations. The reduced temperature and reduced FIG. 1. Simulation results of the pressure (MPa) of 1 mole of volume are defined as follows Argon, as a function of reduced temperature TR and reduced specific volume VR. TR = exp((ii − 1)·0.1),

VR = exp((jj − 1)·0.25), where ii ranges from 1 to 20, and where jj ranges from 1 to 10. The actual temperature of the argon is simply T = TR·Tc, where the critical temperature Tc of argon is 3 150.687 K. The actual volume of the sphere Vsphere (m ) for one mole of argon was determined from the reduced 3 volume VR, the specific density ρc=535 kg/m , and the molar mass MM =39.9 g/mole simply by

VR·MM Vsphere = , (46) ρc and thus the radius Rsphere (m) and surface area Asphere 2 3 (m ) of the sphere can be determined from Vsphere (m ) with equation 23. The reduced specific volumes VR and reduced specific temperatures TR, as well as the pressures determined with the model Pkin (kPa), as well as the internal en- ergy U (kJ), are plotted in Figure 1 and Figure 2. In the parametric simulation, the numerical prediction for the pressure matched the Peng-Robinson PPR (equation 30) pressures within less than 5% error, and the correla- FIG. 2. Simulation results of the internal energy U (kJ) of 1 tion R between the simulated results and Peng-Robinson mole of Argon, as a function of reduced temperature TR and equation is 0.990. reduced specific volume VR. At the colder and more dense parameters, the argon gas is far from ideal, where the pressure follows the equa- tion of state defined in equation 7; a simulation will be considered to be ideal if its simulated pressure matches the ideal gas pressure with an error of less than 5%. In Figure 3, all of the ideal-gas parameters are colored in red, and the non-ideal parameters are colored blue; 76 the entropy of a system of molecules increases, the stan- out of the 200 parametric simulations was determined to dard deviations of the molecular positions and/or veloc- represent ideal-gas argon. From these ideal gas parame- ities would increase. The entropy of the ideal-gas argon ters, the entropy was first determined with equation 22. was compared to the standard deviations of the argon Entropy is a measure of the disorder of a system, and molecule position σX (m) and velocity σV (m/s), and an the number of possible positions and velocities of a molec- empirical equation for the entropy as a function of the ular system, and so it would make logical sense that as standard deviations was obtained (equation 47) with a 8

FIG. 3. Location of parametric simulations that was deter- FIG. 4. Comparison of the entropy for the 76 parametric sim- mined to represent an ideal gas, where the pressure matched ulations (out of 200) that are considered to be an ideal gas de- within 5% of the ideal gas pressure defined in equation 7. fined with equation 7 (Figure 3); the value of Sanalytical (J/K) is defined with the analytical equation 22, and Sempirical (J/K) is defined with the empirical equation 47. correlation of R=0.9909 (Figure 4). √ √ Sempirical = Φ1 + Φ2· σV + Φ3· σX , (47) q 2 2 2 σX (m) = σX,x + σX,y + σX,z,

q 2 2 2 σV (m/s) = σV,x + σV,y + σV,z, J Φ = 106.239 , 1 K J r s Φ = 918.9098·10−4 , 2 K m J r 1 Φ = 0.13937·10−4 . 3 K m The combined position and velocity standard deviation of all of the parameters, both ideal-gas parameters and real-gas parameters, are plotted in Figures 5 and 6, re- spectively. Taking these standard deviations, and using them in the empirical equation 47, the entropy S (J/K) of every parameter in this simulation is plotted in Figure FIG. 5. Location standard deviation σX (m) of the parametric 7. study. The change in entropy for a mole of ideal-gas monatomic argon held at a constant volume would be calculated simply as and the change in the internal energy U can be deter- mined from the data plotted in Figure 2. The empirical δS = Q/T = 1.5·R ·δT /T, U equation found (equation 49) calculates the change in en- however, this only applies to ideal gases. The rate of tropy δSδv=0 (J/K) of isochoric heating as a function of change in the entropy (Figure 7) was calculated, first the heat input Q (J), the position standard deviation σX for isochoric heating (constant volume), yielding 19·10 (m), and the velocity standard deviation σV (m/s), or 190 different calculated rates of change, encompassing both ideal and real argon undergoing isochoric heating. δSδv=0 = T1·Q + T2·σV + T3·σX , (49) It is desired to find an empirical equation for the change 1 in entropy as a function of the position σ (m) and ve- T = 7.7664·10−4 , X 1 K locity σV (m/s) standard deviation, as well as the heat −4 J·s input Q (J). The heat input at a constant volume can be T2 = 17.6815·10 , determined with the first law (equation 1), and thus K·m J T = 9.1519 . Q = δU, (48) 3 K·m 9

FIG. 6. Velocity standard deviation σV (m/s) of the para- FIG. 8. The rate of change in entropy δSδv=0 (K) for isochoric metric study. heating, comparing both the entropy data in Figure 7, and using the empirical equation 49. The empirical equation was found to match the numerical data with a correlation R of 0.99025.

determined with the numerically obtained pressures plot- ted in Figure 1. The empirical equation found (equation 51) calculates the change in entropy δSδT =0 (J/K) of isothermal expansion heating as a function of the heat input Q (J), the position standard deviation σX (m), and the velocity standard deviation σV (m/s),

σX δSδT =0 = V1·Q· , (51) σV J V = 311, 594.4735 . 1 K·s This equation 51 was found to match the change in en- tropy of the data in Figure 7 with a correlation R of 0.99433 (Figure 9). FIG. 7. Entropy S (J/K) calculated with equation 47 as a function of both the (Figure 5) location standard deviation σ (m) and the (Figure 6) velocity standard deviation σ X V VI. THE SUPERCRITICAL STIRLING CYCLE (m/s) of the parametric study. HEAT ENGINE

This equation 49 was found to match the change in en- The supercritical Stirling cycle heat engine was ana- tropy of the data in Figure 7 with a correlation R of lyzed in an earlier effort [16], where a real fluid (argon) 0.99025 (Figure 8). is compressed isothermally at a cold temperature (Stage The rate of change in the entropy (Figure 7) was next 1-2), heated at a constant volume to a hot temperature calculated for isothermal expansion (constant tempera- (Stage 2-3), expanded isothermally at the hot tempera- ture), yielding 20·9 or 180 different calculated rates of ture (Stage 3-4), and cooled at a constant volume back to change, encompassing both ideal and real argon undergo- the original cold temperature (Stage 4-1). The numerical ing isothermal expansion heating. The heat input during results at the end of this parametric study can represent isothermal expansion can be determined with the first a supercritical Stirling cycle, where the coldest tempera- law (equation 1), and thus ture data is used for the isothermal compression (Stage 1-2), the smallest volume data is used for the isochoric Q = δU + P ·δV , (50) heating (Stage 2-3), the hottest temperature data is used for the isothermal expansion (Stage 3-4), and the largest where the change in the internal energy δU (J) can be volume is used for the isochoric cooling (Stage 4-1). The determined from the data plotted in Figure 2, and the numerically obtained reduced pressure PR and reduced 3 change in pressure P (Pa) and volume δV (m ) can be specific volume VR of this cycle is plotted in Figure 10. 10

FIG. 9. The rate of change in entropy δSδT =0 (K) for isother- FIG. 11. The change in internal energy δU (J) obtained from mal expansion, comparing both the entropy data in Figure 7, Figure 2, the work input and output W (J) obtained with and using the empirical equation 51. The empirical equation equation 2, and the heat input and output Q (J) obtained was found to match the numerical data with a correlation R with equations 48 and 50; for the supercritical Stirling cycle of 0.99433. heat engine defined in Figure 10.

FIG. 12. The cumulative change in entropy δS (J/K) for FIG. 10. Reduced pressure PR and reduced specific volume the supercritical Stirling cycle heat engine defined in Figure VR for the supercritical Stirling cycle heat engine. 10; both δSU (J/K) defined with equation 4, and δSσ (J/K) defined with the numerical simulation results (Figure 7).

The change in internal energy δU (J), work input and output W = P ·δV (J) obtained with equation 2, and VII. CONCLUSION heat input Q (J) determined with equations 48 and 51, are plotted in Figure 11. The change in entropy to the surrounding δSU assumes Within Figure 12, the change in entropy determined heat transfer occurs at a virtually identical temperature with equation 47 (Figure 7) is plotted as δSσ (J/K), between the surrounding and the argon. As expected, it alongside the cumulative change in entropy δSU (J/K) is clear looking at Figure 12 that while the entropy of the plotted as a function of the heat input Q (J) over the fluid increases, the entropy of the surrounding universe temperature T (K), as defined in equation 4. Assuming is decreasing (and vice versa); it is observed, however, the surrounding environment is an ideal gas, and heat that the magnitude in the change in entropy is consis- transfer always occurs at the temperature of the argon tently different despite the fact that identical heat trans- (nil temperature differential), it is observed that δSU and fer occurs at identical temperatures. The net change in R R δSσ do not match perfectly. entropy at the conclusion of this cycle ( δSU − δSσ) is 11

-1.7463 J/K, suggesting a net reduction of entropy to the spherical container. In empirical equation 49, there is a universe for each revolution of one mole of high-pressure clear positive correlation between the increase in entropy argon throughout this cycle, due to the intermolecular (for a given heat input) and the standard deviation of attractive Van der Waal force [16]. In addition, the net the molecules velocity and position for isochoric heating. R entropy of the high-pressure argon working fluid δSσ is The discrepancy in entropy makes it clear that the ideal- 0 J/K as this cycle is internally reversible. gas equation for entropy (equation 4), while absolutely One observation is that the total entropy of the real- appropriate for idea gases, does not apply to real non- fluid argon, when utilizing the empirical equation 47 ideal fluids if trying to determine the disorder and the and the numerically obtained standard deviations for the number of states as defined by Boltzman’s equation 6. molecule position σX (m) and velocity σV (m/s), is con- This study makes it clear that entropy is better defined sistently greater than for a mole of ideal gas argon of by looking at the numerically obtained standard devia- comparable temperature (equation 22). The intermolec- tions of the positions σX (m) and velocity σV (m/s), and ular attractive forces add to the RMS velocities (typically using the empirical equation 47 when dealing with real 10% increase), and require the molecules to travel (on av- fluids subjected to the intermolecular attractive Van der erage) a longer spatial distance to move throughout the Waal forces.

[1] Sadi Carnot, E. Clapeyron, Rudolph Clausius, and for a nanomechanical engine beyond the carnot limit. E. Mendoza. Reflections on the Motive Power of Fire Physical Review X, 7:031044, 13 September 2017. and other Papers on the Second Law of Thermodynam- http://doi.org/10.1103/PhysRevX.7.031044. ics. Dover Publications Inc, Mineola, NY, 1960. [15] Nelly Huei Ying Ng, Mischa Prebin Woods, and [2] Enrico Fermi. Thermodynamics. Dover Publications Inc, Stephanie Wehner. Surpassing the carnot effi- New York, NY, 1936. ciency by extracting imperfect work. New Jour- [3] Yunus A. Cengel and Michael A. Boles. Thermodynam- nal of Physics, 19:113005, 7 November 2017. ics, An Engineering Approach Sixth Edition. McGraw http://doi.org/10.1088/1367-2630/aa8ced. Hill Higher Education, Columbus OH, 2008. [16] Matthew Marko. The saturated and supercritical stirling [4] Daniel V. Schroeder. An Introduction to Thermal cycle thermodynamic heat engine cycle. AIP Advances, Physics. Addison Wesley Longman, Boston MA, 2000. 8(8):085309, 2018. http://doi.org/10.1063/1.5043523. [5] Terrell L. Hill. An Introduction to Statistical Thermody- [17] M. Born and H.S. Green. A general kinetic the- namics. Dover Publications, 1960, 1960. ory of liquids, the molecular distribution functions. [6] R. K. Pathria. Statistical Mechanics, 2nd Edition. Proceedings of the Royal Society of London Series Butterworth-Heinemann, 30 Corporate Drive, Suite 400, A Mathematical and Physical Sciences, 188, 1946. Burlington, MA 01803 USA, 1972. http://doi.org/10.1098/rspa.1946.0093. [7] Rongjia Yang. Is gravity entropic force. MDPI Entropy, [18] Otto. Redlich and J. N. S. Kwong. On the thermody- 16:4483–4488, 2014. http://doi.org/10.3390/e16084483. namics of solutions. v. an equation of state. fugacities [8] Takashi Torii. Violation of the third law of of gaseous solutions. Chemical Reviews, 44(a):233–244, black hole thermodynamics in higher curvature 1949. http://doi.org/10.1021/cr60137a013. gravity. MDPI Entropy, 14:2291–2301, 2012. [19] Ding-Yu Peng and Donald B. Robinson. A new http://doi.org/10.3390/e14112291. two-constant equation of state. Industrial and En- [9] Oyvind Gron. Entropy and gravity. MDPI Entropy, gineering Chemistry Fundamentals, 75(1):59–64, 1976. 14:2456–2477, 2012. http://doi.org/10.3390/e14122456. http://doi.org/10.1021/i160057a011. [10] Jeroen Schoenmaker. Historical and physical ac- [20] Kenneth S. Pitzer. Origin of the acentric factor. Ameri- count on entropy and perspectives on the second law can Chemical Society Symposium Series, Phase Equilib- of thermodynamics for astrophysical and cosmologi- ria and Fluid Properties in the Chemical Industry, 60. cal systems. MDPI Entropy, 16:4430–4442, 2014. [21] W.H. Keesom. The second viral coefficient for rigid http://doi.org/10.3390/e16084420. spherical molecules, whose mutual attraction is equiva- [11] Alessandro Pesci. Entropy bounds and field lent to that of a quadruplet placed at their centre. Royal equations. MDPI Entropy, 17:5799–5810, 2015. Netherlands Academy of Arts and Sciences Proceedings, http://doi.org/10.3390/e17085799. 18 I:636–646, 1915. [12] Er Shi, Xiaoqin Sun, Yecong He, and Changwei Jiang. [22] Fabio L. Leite, Carolina C. Bueno, Alessandra L. Da Effect of a magnetic quadrupole field on entropy genera- R´oz, Ervino C. Ziemath, and Osvaldo N. Oliveira tion in thermomagnetic convection of paramagnetic fluid Jr. Theoretical models for surface forces and adhe- with and without a gravitational field. MDPI Entropy, sion and their measurement using atomic force mi- 19:96, 2017. http://doi.org/10.3390/e19030096. croscopy. MDPI Molecular Sciences, 13:12773–12856, [13] J. Rossnagel, F. Schmidt-Kaler O. Abah, K. Singer, , and 2012. http://doi.org/10.3390/ijms131012773. E. Lutz. Nanoscale heat engine beyond the carnot limit. [23] The General Theory of Molecular Forces. F. london. Physical Review Letters, 112:030602, 22 January 2014. Transactions of the Faraday Society, 33:8–26, 1937. http://doi.org/10.1103/PhysRevLett.112.030602. http://doi.org/10.1039/TF937330008B. [14] Jan Klaers, Stefan Faelt, Atac Imamoglu, and Emre [24] Roger H. French. Origins and applications of lon- Togan. Squeezed thermal reservoirs as a resource don dispersion forces and hamaker constants in ce- 12

ramics. Journal of the American Ceramic Soci- state for argon covering the fluid region for temperatures ety, 83:2117–2146, 2000. http://doi.org/10.1111/j.1151- from the melting line to 700 k at pressures up to 1000 2916.2000.tb01527.x. mpa. Journal of Physical Chemistry Reference Data, [25] A. D. McLachlan. Retarded dispersion forces 28(3):779–850, 1999. http://doi.org/10.1063/1.556037. in dielectrics at finite temperatures. Proceedings [38] M. A. Anisimov, A. T. Berestov, L. S. Veksler, B. A. of the Royal Society of London. Series A, Math- Kovalchuk, and V. A. Smirnov. Scaling theory and the ematical and Physical Sciences, 274:80–90, 1963. equation of state of argon in a wide region around the http://doi.org/10.1098/rspa.1963.0115. critical point. Soviet Physics JETP, 39(2):359–365, 1974. [26] M.H. Hawton, V.V. Paranjape, and J. Mahanty. Tem- [39] Kwan Y Kim. Calorimetric studies on argon and hex- perature dependence of dispersion interaction, ap- afluoro ethane and a generalized correlation of maxima plication to van der waals forces and the po- in isobaric heat capacity. PhD Thesis, Department of laron. Physical Review B, 26:1682–1688, 1982. Chemical Engineering, University of Michigan, 1974. http://doi.org/10.1103/PhysRevB.26.1682. [40] William D. McCain Jr and Waldemar T. Ziegler. [27] P.J. Linstrom and Eds W.G. Mallard. NIST Chem- The critical temperature, critical pressure, and istry WebBook, NIST Standard Reference Database of argon. Journal of Chemi- Number 69. National Institute of Standards and cal and Engineering Data, 12(2):199–202, 1967. Technology, Gaithersburg MD, 20899, April 29 2018. http://doi.org/10.1021/je60033a012. http://doi.org/10.18434/T4D303. [41] O. Sifner and J. Klomfar. Thermodynamic properties of [28] Reiner Tillner-Roth and Hans Dieter Baehr. An inter- xenon from the triple point to 800 k with pressures up to national standard formulation for the thermodynamic 350 mpa. Journal of Physical Chemistry Reference Data, properties of 1,1,1,2-tetrafluoroethane (hfc-134a) for tem- 23(1):63–152, 1994. http://doi.org/10.1063/1.555956. peratures from 170 k to 455 k and pressures up to 70 [42] James A. Beattie, Roland J. Barriault, and James S. mpa. Journal of Physical and Chemical Reference Data, Brierley. The compressibility of gaseous xenon. ii. 23(5):657–729, 1994. http://doi.org/10.1063/1.555958. the virial coefficients and potential parameters of [29] Roland Span, Eric W. Lemmon, Richard T Jacobsen, xenon. Journal of Chemical Physics, 19:1222, 1951. Wolfgang Wagner, and Akimichi Yokozeki. A refer- http://doi.org/10.1063/1.1748000. ence equation of state for the thermodynamic proper- [43] H. H. Chen, C. C. Lim, and Ronald A. Aziz. The en- ties of nitrogen for temperatures from 63.151 to 1000 thalpy of vaporization and internal energy of liquid ar- k and pressures to 2200 mpa. Journal of Physical gon, krypton, and xenon determined from vapor pres- and Chemical Reference Data, 29(6):1361–1433, 2000. sures. Journal of Chemical Thermodynamics, 7:191–199, http://doi.org/10.1063/1.1349047. 1975. http://doi.org/10.1016/0021-9614(75)90268-2. [30] W. Wagner and A. Prub. The iapws formulation 1995 [44] Richard T. Jacobsen and Richard B. Stewart. Thermody- for the thermodynamic properties of ordinary water sub- namic properties of nitrogen including liquid and vapor stance for general and scientific use. Journal of Physi- phases from 63k to 2000k with pressures to 10,000 bar. cal and Chemical Reference Data, 31(2):387–535, 2002. Journal of Physical Chemistry Reference Data, 2(4):757– http://doi.org/10.1063/1.1461829. 922, 1973. http://doi.org/10.1063/1.3253132. [31] U. Setzmann and W. Wagner. A new equation of state [45] Lester Haar and John S. Gallagher. Thermody- and tables of thermodynamic properties for methane namic properties of ammonia. Journal of Phys- covering the range from the melting line to 625 k ical Chemistry Reference Data, 7(3):635–792, 1978. at pressures up to 100 mpa. Journal of Physical http://doi.org/10.1063/1.555579. and Chemical Reference Data, 20(6):1061–1155, 1991. [46] Nathan S. Osborne, Harold F. Stimson, and Defoe C. http://doi.org/10.1063/1.555898. Ginnings. Measurements of heat capacity and heat of [32] Daniel G. Friend, Hepburn Ingham, and James F. Fly. vaporization of water in the range 0 to 100 C. Part of Thermophysical properties of ethane. Journal of Phys- Journal of Research of the National Bureau of Standards, ical and Chemical Reference Data, 20(2):275–347, 1991. 23:197–260, 1939. http://doi.org/10.1063/1.555881. [47] N. S. Osborne, H. F . Stimson, and D. C. Ginnings. [33] H. Miyamoto and K. Watanabe. A thermodynamic Calorimetric determination of the thermodynamic prop- property model for fluid-phase propane. Interna- erties of saturated water in both the liquid and gaseous tional Journal of Thermophysics, 21(5):1045–1072, 2000. states from 100 to 374 C. J. Research NBS, 18(389):983, http://doi.org/10.1023/A:1026441903474. 1937. [34] H. Miyamoto and K. Watanabe. Thermodynamic [48] H. Sato, K. Watanabe, J.M.H Levelt Sengers, J.S. Gal- property model for fluid-phase n-butane. Interna- lagher, P.G. Hill, J. Straub, and W. Wagner. Six- tional Journal of Thermophysics, 22(2):459–475, 2001. teen thousand evaluated experimental thermodynamic http://doi.org/10.1023/A:1010722814682. property data for water and steam. Journal of Phys- [35] H. Miyamoto and K. Watanabe. A thermodynamic ical Chemistry Reference Data, 20(5):1023–1044, 1991. property model for fluid-phase isobutane. Interna- http://doi.org/10.1063/1.555894. tional Journal of Thermophysics, 23(2):477–499, 2002. [49] Leighton B. Smith and Frederick G. Keyes. The vol- http://doi.org/10.1023/A:1015161519954. umes of unit mass of liquid water and their correlation [36] Richard B. Stewart and Richard T. Jacobsen. Ther- as a function of pressure and temperature. Procedures of modynamic properties of argon from the triple point American Academy of Arts and Sciences, 69:285, 1934. to 1200 k with pressures to 1000 mpa. Journal of http://doi.org/10.2307/20023049. Physical Chemistry Reference Data, 18(1):639–798, 1989. [50] Nathan S. Osborne, Harold F. Stimson, and Defoe C. http://doi.org/10.1063/1.555829. Ginnings. Thermal properties of saturated water and [37] Ch. Tegeler, R. Span, and W. Wagner. A new equation of steam. Journal of Research of the National Bureau of 13

Standards, 23:261–270, 1939. [51] D. M. Murphy and T. Koop. Review of the vapor pres- sures of ice and supercooled water for atmospheric appli- cations. Q. J. R. Meteorological Society, 131:1539–1565, 2005. http://doi.org/10.1256/qj.04.94. [52] B. A. Younglove and J. F. Ely. Thermophysi- cal properties of fluids, methane, ethane, propane, isobutane, and normal butane. Journal of Physi- cal Chemistry Reference Data, 16(4):577–798, 1987. http://doi.org/10.1063/1.555785. [53] Manson Benedict, George B. Webb, and Louis C. Ru- bin. An empirical equation for thermodynamic proper- ties of light hydrocarbons and their mixtures i. methane, ethane, propane and nbutane. AIP Journal of Chemical Physics, 8:334, 1940. http://doi.org/10.1063/1.1750658. [54] John Edward Lennard-Jones. On the deter- mination of molecular fields. Proceedings of the Royal Society A, 106(738):463–477, 1924. http://doi.org/10.1098/rspa.1924.0082. 14

FORTRAN CODE

program MakeInput implicit none

real Vr,Tr,Vr_Fct(200),Tr_Fct(200) real U,S_entropy,P_kinetic,P_PR double precision pi,Kb,Av real t1,t2,Rat(100),outputdat(22) integer fooint,ct,ctx,ii,jj,kk,ppnum character(len=17) filenameSV

call CPU_Time(t1)

pi=3.1415926535897932384626 Kb=1.38064852e-23 ! Boltzman’s Constant Av=6.02214086e23 ! Avogadro’s Number c ---- Run a parametric series, first four separate heating simulations, c ---- then four stages of the high-pressure Stirling cycle

ct=0 do ii=1,20 Tr=1.0*exp((ii-1)*0.10) do jj=1,10 ct=ct+1 Vr=1.0*exp((jj-1)*0.25) Tr_Fct(ct)=Tr Vr_Fct(ct)=Vr enddo enddo

ctx=200 open(unit=1000,file=’param_output_data_study_8sept2020.txt’) ppnum=0

do ii=1,200 ppnum=ppnum+1 Tr=Tr_Fct(ii) Vr=Vr_Fct(ii) call ThermoCalc(Vr,Tr,ppnum,outputdat) call CPU_Time(t2)

if (ppnum<10) then write(filenameSV,’("Save_00",I1,".txt")’)ppnum elseif (ppnum<100) then write(filenameSV,’("Save_0",I2,".txt")’)ppnum elseif (ppnum<1000) then write(filenameSV,’("Save_",I3,".txt")’)ppnum endif open(unit=ppnum,file=filenameSV) write(ppnum,*) ppnum,Vr,Tr,outputdat,’t (s) = ’,(t2-t1) close(ppnum) 15

write(1000,*) ppnum,Vr,Tr,outputdat,’t (s) = ’,(t2-t1) print *,ppnum,’/’,ctx,’t (s) = ’,t2 enddo

close(1000)

end program c ------Analysis Subroutine ------

subroutine ThermoCalc(Vr,Tr,ppnum,outputdat)

real, intent(in) :: Vr,Tr integer, intent(in) :: ppnum real, intent(out) :: outputdat(22)

integer ctsplitrng,ctsplit,fooint

real U,S_entropy,P_kinetic,P_PR real t1,t2 double precision MM,Pc,Tc,Vc,ecc,V,T,Rg,a,b,R,AreaS,minVr double precision kappa,a_PR,xx(3),Vx(3),Vx0(3),RMS3(3) double precision Coeff double precision dP_VWD, F_VDW_m,phi,theta,Vel,dP_VDW,V_rms_0,V_avg_0 double precision drX,Vel_travel(3),Vel_xx double precision VelF,Vrat(3),Xrat(3) double precision VXdot,dP_Pauli,P_IG,U_KE,U_PE double precision Read6(6),Avg6(6),StDev6(6),V_rms_calc,V_avg_calc

character (len=200) output integer ii,ii0,jj,jj0,kk,ct,dir(3) integer dx0, Nx, Ny, Np, Total_CT double precision bp,aa double precision pi,Kb,Av,m_m,dt,Fx(3),fooV(2) double precision, allocatable :: phi_fct(:),theta_fct(:),rrX(:,:) double precision, allocatable :: VXrat(:),F_dat(:),VelFdat(:) double precision, allocatable :: Vel_travelDat(:),Vel_fct(:) double precision, allocatable :: Xstore(:,:),Vstore(:,:) double precision, allocatable :: Fx_Stored(:,:) double precision, allocatable :: foocrap(:),randnum(:) integer, allocatable :: Tct(:),Total_Ct_Fct(:)

character(len=15) filenameSV

call CPU_Time(t1) c ------Make Source ------

pi=3.1415926535897932384626 Kb=1.38064852e-23 Av=6.02214086e23 16

dx0=300 ! Estimated time steps per bounce Nx=91 ! Number of steps in each degree (square it in theta and phi) Ny=101 ! Number of steps at each degree increment, varying speed randomly ctsplit=500 ! Number of files to save all data (avoid limit of memory) c --- Argon MM=.0399 ! Molar Mass (kg/mole) Pc=4.863e6 ! Critical Pressure (Pa) Tc=150.687 ! Critical Temperature (K) Vc=1./535 ! Critical Volume (m^3/kg) ecc=0 ! Eccentricity factor

c______

Np=(Nx**2)*Ny ! Total number of molecules bouncing in the spherical container

if ((mod(Np,ctsplit))==0) then ctsplitrng=(Np/ctsplit) else ctsplitrng=(Np/ctsplit)+1 endif print *,ctsplitrng

ALLOCATE(rrX(Np,3)) ALLOCATE(Tct(Np)) ALLOCATE(VXrat(Np)) ALLOCATE(F_dat(Np)) ALLOCATE(VelFdat(Np)) ALLOCATE(Vel_travelDat(Np)) ALLOCATE(Vel_fct(Np)) ALLOCATE(Xstore((dx0*10),3)) ALLOCATE(Vstore((dx0*10),3)) ALLOCATE(Fx_Stored((dx0*10),3)) ALLOCATE(randnum(Ny)) ALLOCATE(Total_Ct_Fct(ctsplit))

ALLOCATE(foocrap(Np))

V=Vr*Vc*MM ! Actual volume (m^3) T=Tr*Tc ! Actual temperature (K)

m_m=MM/Av ! Mass of Argon molecule Rg=Av*Kb/MM ! Gas Constant c --- Peng-Robinson Equation of State coefficients a=0.45724*(Rg**2)*(Tc**2)/Pc b=0.07780*Rg*Tc/Pc c --- Ensure the volume is not excessively small minVr=1./100 if (Vr<((1+minVr)*b/Vc)) then V=((1+minVr)*b/Vc)*Vc*MM endif c --- Coefficient for change in internal energy 17

bp=(2.**(1./3))-1. aa=(1/(9*bp))*(Rg**2)*(Tc**2.5)/Pc c --- R = Radius of Sphere; Rb = equivalent radius of sphere (Pauli Exclusion)

R=(V*(3./(4*pi)))**(1./3) Rb=((V-(b*MM))*(3./(4*pi)))**(1./3) AreaS=4*pi*(R**2) ! Surface Area of sphere

V_rms_0=sqrt(3*Kb*T/m_m) ! RMS velocity of molecule V_avg_0=V_rms_0*(sqrt(8/(3*pi))) ! Average velocity of molecule c --- Determine pressure from Peng-Robinson Equation of State kappa=0.37464+(1.54226*ecc)-(0.26992*(ecc**2)) a_PR=(1.+(kappa*(1-(sqrt(T/Tc)))))**2 P_PR=((Rg*T)/((V/MM)-b)) P_PR=P_PR-((a_PR*a)/((((V/MM)**2)+(2*b*(V/MM))-(b**2))))

dt=(2*R/V_avg_0)/dx0 ! Time step (s) c --- Set function of angles in X-Y-Z coordinates ct=0 do jj=1,Nx phi=(pi/2)*((jj-1.)/(Nx-1.)) do ii=1,Nx ct=ct+1 theta=(pi)*((ii-1.)/(Nx-1.)) xx(1)=(sin(theta))*(cos(phi)) xx(2)=(sin(theta))*(sin(phi)) xx(3)=cos(theta)

do kk=1,Ny rrX(((ct-1)*Ny)+kk,1)=xx(1) rrX(((ct-1)*Ny)+kk,2)=xx(2) rrX(((ct-1)*Ny)+kk,3)=xx(3) enddo enddo enddo c --- Call velocity spread function (if Ny>1) call make_rand_fct(Ny,randnum) c --- Confirm ratio of V_rms_calc / V_avg_calc = (pi*4/3)^(1/3) V_rms_calc=0 V_avg_calc=0 do ii=1,Ny V_avg_calc=V_avg_calc+(randnum(ii)*V_avg_0/Ny) V_rms_calc=V_rms_calc+(((randnum(ii)*V_avg_0)**2)/Ny) enddo V_rms_calc=sqrt(V_rms_calc) c --- Set velocity function do ii=1,(Nx**2) 18

do jj=1,Ny ii0=((ii-1)*Ny)+jj if (Ny==1) then Vel_fct(ii0)=V_rms_0 else c Vel_fct(ii0)=V_rms_0 Vel_fct(ii0)=(randnum(jj))*V_avg_0 endif enddo enddo c ------Make Source ------

ii=0 Total_CT=0 Total_CT0=0 c --- Actually run the simulation, and saving X-Y-Z data of molecule until c --- it reaches the opposing surface of the spherical container

do ii0=1,ctsplit

if ((ii+ctsplitrng)>Np) then fooint=Np-ii else fooint=ctsplitrng endif

if (ii0<10) then write(filenameSV,’("SaveXV3_00",I1,".txt")’)ii0 elseif (ii0<100) then write(filenameSV,’("SaveXV3_0",I2,".txt")’)ii0 elseif (ii0<1000) then write(filenameSV,’("SaveXV3_",I3,".txt")’)ii0 endif open(unit=ii0,file=filenameSV) do jj0=1,fooint ii=ii+1

call Get_dP_VDW(Vel_fct(ii),Vr,dP_VDW) F_VDW_m=dP_VDW*AreaS/Av Vx0=(Vel_fct(ii))*(rrX(ii,:)) Vx=Vx0 xx=xx*0 xx(1)=-R drX=(sqrt(sum(xx**2)))*(0.99)

Xstore=Xstore*0 Vstore=Vstore*0 Fx_Stored=Fx_Stored*0 ct=0 do while ((abs(drX/R))<1.0) ct=ct+1 xx=xx+(Vx*dt) drX=(sqrt(sum(xx**2))) 19

do jj=1,3 if (xx(jj)==0) then dir(jj)=0 else dir(jj)=-(xx(jj)/(abs(xx(jj)))) endif enddo Fx=(abs(F_VDW_m*((xx/R)**3)))*dir do jj=1,3 Vx(jj)=Vx(jj)+(Fx(jj)*dt/m_m) enddo write(ii0,*) xx(:),Vx(:) do jj=1,3 Xstore(ct,jj)=xx(jj) Vstore(ct,jj)=Vx(jj) Fx_Stored(ct,jj)=Fx(jj) enddo if (ct>(dx0*10)) then drX=10*R print *,’PROBLEM!!!’,ct,dx0 endif enddo

Tct(ii)=ct Total_CT0=Total_CT0+ct Total_CT=Total_CT+ct Vel_travel=Vel_travel*0 do jj=1,3 fooreal1=0 do kk=1,ct fooreal1=fooreal1+(Vstore(kk,jj)/ct) enddo Vel_travel(jj)=fooreal1 enddo do jj=1,3 Vel_travelDat(ii)=Vel_travelDat(ii)+(Vel_travel(jj)**2) enddo Vel_travelDat(ii)=sqrt(Vel_travelDat(ii))

VelF=0 do jj=1,3 VelF=VelF+(Vstore(ct,jj)**2) enddo VelF=sqrt(VelF) VelFdat(ii)=VelF

Vrat=Vstore(ct,:)/VelF Xrat=xx/R

VXdot=0 do jj=1,3 VXdot=VXdot+(Xrat(jj)*Vrat(jj)) enddo VXrat(ii)=VXdot 20 c ------Calculate the force, to numerically determine the pressure F_dat(ii)=((2*m_m*VXdot)*VelF/(ct*dt))-F_VDW_m

enddo close(ii0) Total_Ct_Fct(ii0)=Total_Ct0 Total_Ct0=0 enddo c --- Calculate the average and RMS position and velocity of the molecules

Avg6=Avg6*0. RMS3=RMS3*0. StDev6=StDev6*0.

do jj=1,ctsplit

if (jj<10) then write(filenameSV,’("SaveXV3_00",I1,".txt")’)jj elseif (jj<100) then write(filenameSV,’("SaveXV3_0",I2,".txt")’)jj elseif (jj<1000) then write(filenameSV,’("SaveXV3_",I3,".txt")’)jj endif open(unit=jj,file=filenameSV)

do ii=1,(Total_Ct_Fct(jj)) read(jj,*) Read6(:) Avg6=Avg6+Read6 RMS3=RMS3+(Read6(4:6)**2.) enddo close(jj) enddo Avg6=Avg6/Total_CT RMS3=sqrt(RMS3/Total_CT) c --- Calculate the standard deviation position and velocity of the molecules

do jj=1,ctsplit

if (jj<10) then write(filenameSV,’("SaveXV3_00",I1,".txt")’)jj elseif (jj<100) then write(filenameSV,’("SaveXV3_0",I2,".txt")’)jj elseif (jj<1000) then write(filenameSV,’("SaveXV3_",I3,".txt")’)jj endif open(unit=jj,file=filenameSV)

do ii=1,(Total_Ct_Fct(jj)) read(jj,*) Read6(:) StDev6=StDev6+((Read6-Avg6)**2) enddo close(jj) enddo StDev6=StDev6/Total_CT 21

c --- Output results of this specific trial

P_kinetic=0 U_KE=0 S_entropy=0 do ii=1,Np P_kinetic=P_kinetic+(F_dat(ii)) U_KE=U_KE+(VelFdat(ii)**2) S_entropy=S_entropy+(Vel_travelDat(ii)) enddo

P_kinetic=((P_kinetic/Np)*(Av/AreaS))*(R/Rb) P_IG=Av*Kb*T/V

U_KE=((U_KE/Np))*(0.5*Av*m_m) U_PE=-dP_VDW*V U=U_KE+U_PE S_entropy=((3*log(S_entropy/Np))+(log(V-(b*MM))))*Av*Kb

outputdat(1)=U outputdat(2)=S_entropy outputdat(3)=P_kinetic outputdat(4)=P_PR outputdat(5:10)=Avg6 outputdat(11:16)=StDev6 outputdat(17:19)=RMS3 outputdat(20)=Total_CT outputdat(21)=V_rms_calc outputdat(22)=V_avg_calc

end subroutine c ======c ======c --- Subroutine to calculate intermolecular attractive force component c --- Equation developed to match Peng-Robinson equation of state

subroutine Get_dP_VDW(Vel,Vr,dP_VDW)

real, intent(in) :: Vr double precision, intent(in) :: Vel double precision, intent(out) :: dP_VDW double precision pi,Kb,Av,m_m,T_eff,Tr,Pc double precision MM,Tc,Vc,V,R,Coeff,Rb,bp,aa integer ii

pi=3.1415926535897932384626 Kb=1.38064852e-23 Av=6.02214086e23 c Argon 22

MM=.0399 ! Molar Mass (kg/mole) Pc=4.863e6 ! Critical Pressure (Pa) Tc=150.687 ! Critical Temperature (K) Vc=1./535 ! Critical Volume (m^3/kg) c ecc=0 ! Eccentricity factor

V=Vr*Vc*MM

m_m=MM/Av Rg=Av*Kb/MM

bp=(2.**(1./3))-1. aa=(1/(9*bp))*(Rg**2)*(Tc**2.5)/Pc

T_eff=(Vel**2)*m_m/(3*Kb) Tr=T_eff/Tc

if (Tr<1.) then Coeff=(2.3246+(-0.8441/(sqrt(Vr)))+(-0.8670))*Tr else Coeff=2.3246+(-0.8441/(sqrt(Vr)))+(-0.8670*sqrt(Tr)) endif if (Coeff>1) then Coeff=0 endif

dP_VDW=(aa/(sqrt(T_eff)))/((V/MM)**2) dP_VDW=dP_VDW*Coeff

end subroutine c ======c ======c --- Subroutine to distribute velocities of molecules c --- Ensures proper ratio of average and RMS velocity

subroutine make_rand_fct(NN,randdat)

integer, intent(in) :: NN double precision, intent(out) :: randdat(NN)

double precision , allocatable :: NormFct(:),Xfct(:) double precision , allocatable :: NormFct0(:) double precision ctX,x,MinX,stdev0,dx,foo integer ii c ALLOCATE(randdat(NN)) ALLOCATE(Xfct(NN)) ALLOCATE(NormFct0(NN)) ALLOCATE(NormFct(NN))

MinX=0.200 stdev0=0.71 23

dx=((1.-MinX)*2.)/(NN-1)

ctX=0.0 do ii=1,NN x=MinX+((ii-1)*dx) Xfct(ii)=x NormFct(ii)=(exp(-0.5*(((x-1)/stdev0)**2))) ctX=ctX+(1./(exp(-0.5*(((x-1)/stdev0)**2)))) enddo

randdat(1)=MinX do ii=2,NN foo=(((1.-MinX)*2.)*(1./NormFct(ii))/ctX) randdat(ii)=randdat(ii-1)+foo enddo

end subroutine c ======c ======