Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pglpm committed Apr 3, 2024
1 parent f147397 commit ec7ef4e
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 16 deletions.
12 changes: 6 additions & 6 deletions code/idealgas2.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
%% SI units used throughout
%% Simulation of ideal gas in 1D
%% Coordinate z
N = 0.02; % amount of ideal gas
N = 0.27; % amount of ideal gas 0.27 / 0.02
A = 0.01; % area of piston
z0 = 0.6; % initial position of piston
v0 = 0; % initial velocity of piston
T0 = 273.15+25; % initial temperature of gas
m = 10; % mass of piston
k = 80*sqrt(4*pi*A); % heat conductivity
%% Fatm = -1e5 * A; % atmospheric force
k = 0*80*sqrt(4*pi*A); % heat conductivity
Fatm = -1e5 * A; % atmospheric force
%%
R = 8.31446261815; % gas constant
C = 20; % molar heat capacity
Expand All @@ -17,8 +17,8 @@
G = -m*g; % gravity supply of momentum to piston
%%
t0 = 0; % initial time
t1 = 10; % final time, can also be earlier than initial
dt = 0.001; % time step, negative if backward time integration %@
t1 = 1; % final time, can also be earlier than initial
dt = 0.0001; % time step, negative if backward time integration %@
%% adjust final time if not multiple of timestep
t1 = t1 + mod(t1-t0,dt);
%% check if timestep and time interval are consistent
Expand Down Expand Up @@ -74,7 +74,7 @@
%% update temperature of gas
T = U/(C*N);
%% update momentum of piston
P = P + (F + G)*dt;
P = P + (F + G + Fatm)*dt;
%% update velocity of piston
v = P/m;
%% update position of piston
Expand Down
101 changes: 101 additions & 0 deletions code/idealgas_r.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
%% SI units used throughout
%% Simulation of ideal gas in 1D
%% Coordinate z
N = 2.29e-3; % amount of ideal gas 0.27 / 0.02
A = 0.00091649; % area of piston
z0 = 0.061103; % initial position of piston
v0 = 0; % initial velocity of piston
T0 = 273.15+23.5; % initial temperature of gas
m = 0.10668; % mass of piston
k = 10 +0*8*sqrt(4*pi*A); % heat conductivity
Fatm = -1e5 * A; % atmospheric force
%%
R = 8.31446261815; % gas constant
C = 20; % molar heat capacity
H = 18e-6 * (4/3 + 0.7); % viscosity
g = 9.80665; % gravitational acceleration
G = -m*g; % gravity supply of momentum to piston
%%
t0 = 0; % initial time
t1 = 1; % final time, can also be earlier than initial
dt = 0.0001; % time step, negative if backward time integration %@
%% adjust final time if not multiple of timestep
t1 = t1 + mod(t1-t0,dt);
%% check if timestep and time interval are consistent
if (t1-t0)*dt <= 0
error('time interval inconsistent with timestep');
end
%% Save values of all quantities at some steps during the simulation,
%% for subsequente analysis or plotting
%% (saving at all timesteps could be too costly)
Nsaves = 200; % number of timepoints to save during the simulation
%% Calculate time interval for saving
dsave = (t1-t0)/(Nsaves-1);
if abs(dsave) < abs(dt)
error('time interval between saves is smaller than timestep')
end
%% Initialize vectors to contain saved values
tSave = nan(Nsaves,1);
zSave = nan(Nsaves,1);
vSave = nan(Nsaves,1);
TSave = nan(Nsaves,1);
FSave = nan(Nsaves,1);
%% Save initial values
i = 1; % index that keeps count of savepoints
tSave(1) = t0;
zSave(1) = z0;
vSave(1) = v0;
TSave(1) = T0;
FSave(1) = (N*R*T0 - A*H*v0)/z0;
%% Initialize plot
cols = get(0, 'DefaultAxesColorOrder');
plot(tSave(1), zSave(1), 'o','Color',cols(1,:)); axis('tight');
xlabel('time {\it t}/s'); ylabel('position {\it z}/m'); hold on;
%% %@
%% Numerical time integration
%% Initialize
t = t0;
z = z0;
v = v0;
T = T0;
U = C*N*T0;
P = m*v0;
%% loop
while sign(dt)*t < sign(dt)*t1 % possible backward time integration
%% update time
t = t + dt;
%% constitutive relation for force on piston
%% same as *minus* force on gas
F = (N*R*T - A*H*v)/z;
%% constitutive relation for heat flux
Q = k*(T0 - T)*z;
%% update internal energy of gas
U = U + (Q - F*v)*dt;
%% update temperature of gas
T = U/(C*N);
%% update momentum of piston
P = P + (F + G + Fatm)*dt;
%% update velocity of piston
v = P/m;
%% update position of piston
z = z + v*dt; %@
%% Check whether to save & plot at this step
if min(abs([0 dsave] - mod(t-t0, dsave))) <= abs(dt)/2
i = i+1;
tSave(i) = t;
zSave(i) = z;
vSave(i) = v;
TSave(i) = T;
FSave(i) = F;
plot(t, z, 'o','Color',cols(1,:));
pause(0.001);
end %@
end %@
%% Plot trajectory
plot(tSave,zSave,'-','Color',cols(1,:));
figure();
plot(tSave,TSave-273.15,'-','Color',cols(2,:)); axis('tight');
xlabel('time {\it t}/s'); ylabel('temperature {\it T}/C');
%figure();
%plot(tSave,(T0-TSave)*k.*zSave,'-','Color',cols(3,:)); axis('tight');
%xlabel('time {\it t}/s'); ylabel('heat flux {\it Q}/W');
14 changes: 13 additions & 1 deletion portamanabib.bib
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%% Home page: http://magnaspesmeretrix.org
%% Email (remove ZZ): pglZZ[at]portamana.org
%% Created: 2000-08-23T16:53:30+0200
%% Last-Updated: 2024-04-03T09:10:59+0200
%% Last-Updated: 2024-04-03T10:47:13+0200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% NB: This database contains also items whose content's validity I
Expand Down Expand Up @@ -122213,6 +122213,18 @@ @Article{shawetal1990
keywords = {probability theory, probability elicitation}
}

@Article{shearwoodetal2023,
author = {Chris Shearwood and Peter A. Sloan},
title = {The {R{\"u}chardt} experiment revisited: using simple theory, accurate measurement and python based data analysis},
journal = ejp,
year = {2023},
volume = {44},
number = {3},
pages = {035102},
note = {\doi{10.1088/1361-6404/acc5c2}},
keywords = {thermomechanics, ideal gas}
}

@Misc{shelahetal2004,
author = {Saharon Shelah and Mor Doron},
title = {A dichotomy in classifying quantifiers for finite models},
Expand Down
Binary file modified seven-wonders.pdf
Binary file not shown.
76 changes: 67 additions & 9 deletions seven-wonders.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
\pdfinclusioncopyfonts=1
%% Author: PGL Porta Mana
%% Created: 2015-05-01T20:53:34+0200
%% Last-Updated: 2024-04-02T15:32:47+0200
%% Last-Updated: 2024-04-03T20:22:13+0200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifarxiv
\arxivfalse
Expand Down Expand Up @@ -1009,6 +1009,7 @@
\newcommand*{\yS}{S}
\newcommand*{\yB}{H}
\newcommand*{\yte}{T}%temperature
\newcommand*{\yvis}{\lambda}%temperature
%
\newcommand*{\yti}{t_{0}}
\newcommand*{\ytf}{t_{1}}
Expand Down Expand Up @@ -4860,9 +4861,9 @@ \section{General form of the universal laws}
\begin{definition}{General form of the universal balance laws (again)}
\begin{equation*}
\begin{gathered}[t]
\underbracket[0pt]{\textsf{\footnotesize vol.\,integral}(\ytf) = \textsf{\footnotesize vol.\,integral}(\yti) + \int_{\yti}^{\ytf}\!\!\textsf{\footnotesize influx}(t)\,\di t + \int_{\yti}^{\ytf}\!\!\textsf{\footnotesize supply}(t)\,\di t}_{\mathclap{\text{\color{grey}integral fosf}}}
\underbracket[0pt]{\textsf{\footnotesize vol.\,content}(\ytf) = \textsf{\footnotesize vol.\,content}(\yti) + \int_{\yti}^{\ytf}\!\!\textsf{\footnotesize influx}(t)\,\di t + \int_{\yti}^{\ytf}\!\!\textsf{\footnotesize supply}(t)\,\di t}_{\mathclap{\text{\color{grey}integral form}}}
\\[2\jot]
\underbracket[0pt]{\frac{\di\,\textsf{\footnotesize vol.\,integral}(t)}{\di t} = \textsf{\footnotesize influx}(t) + \textsf{\footnotesize supply}(t)}_{\mathclap{\text{\color{grey}differential fosf}}}
\underbracket[0pt]{\frac{\di\,\textsf{\footnotesize vol.\,content}(t)}{\di t} = \textsf{\footnotesize influx}(t) + \textsf{\footnotesize supply}(t)}_{\mathclap{\text{\color{grey}differential form}}}
\end{gathered}
\end{equation*}
If the $\textsf{\footnotesize supply}(t)$ must always be zero, then we have a \emph{conservation law}.
Expand All @@ -4873,7 +4874,7 @@ \section{General form of the universal laws}

\smallskip

\emph{The expressions above are valid in Newtonian mechanics, general relativity, and even quantum theory if the symbols are interpreted as so-called \enquote*{statistical operators}, which encode probabilistic properties.}
\emph{The expressions above are valid in any system of coordinates, and in Newtonian mechanics, general relativity, and even quantum theory if the symbols are interpreted as so-called \enquote*{statistical operators}, which encode probabilistic properties.}
\end{definition}

The individual balances and symbols for matter, momentum, energy, angular momentum, entropy are also presented in table\,\ref{tab:balances} p.\,\pageref{tab:balances}.
Expand Down Expand Up @@ -6558,17 +6559,74 @@ \subsection{Heat flux and power}
\subsection{Constitutive relations for the ideal gas}
\label{sec:int_energy_idealgas}

The general constitutive relations~\eqref{eq:energy_volume_matter} for energy content and~\eqref{eq:heat_power} for energy flux can be applied to many common situations. They need, however, more specific constitutive relations for the internal energy $\yU$, the heat flux $\yQ$, and the momentum flux $\yF$. The variety of constitutive relations for these three quantities is the subject of \furl{https://www.britannica.com/technology/materials-science}{materials science}, and could fill numerous tomes. Some constitutive relations for these quantities are mathematically extremely complex, involving integrals and partial derivatives; this is no surprise, because they reflect the complexity of the materials they model.
The general constitutive relations~\eqref{eq:energy_volume_matter} for energy content and~\eqref{eq:heat_power} for energy flux can be applied to many common situations and with all sorts of materials. They need, however, more specific constitutive relations for the internal energy $\yU$, the heat flux $\yQ$, and the momentum flux $\yF$. The variety of constitutive relations for these three quantities is the subject of \furl{https://www.britannica.com/technology/materials-science}{materials science}, and could fill numerous tomes. Some constitutive relations for these quantities are mathematically extremely complex, involving integrals and partial derivatives; this is no surprise, because they reflect the complexity of the materials they model.

Let us discuss some simple constitutive relations can be used as a first approximation for many gases, especially when they are rarefied, that is, when their amount of matter per unit volume is low. We call them constitutive relations or \emph{ideal gases}. When we say that some material can be modelled as an ideal gas -- or simply say \enquote{it's an ideal gas}, we mean that we can model it with good enough approximation by using this set of constitutive relations.
There is a set of simple constitutive relations which can be used as approximations for many gases, especially when they are rarefied, that is, when their amount of matter per unit volume is low. We say that these constitutive relations apply to \emph{ideal gases}. When we say that some material can be modelled as an ideal gas -- or simply say \enquote{it's an ideal gas}, we mean that we can model it with good enough approximation by using this set of constitutive relations.

\begin{definition}{Internal energy of ideal gas}
If a small control volume contains an amount of matter $\yN$ and has uniform temperature $\yte$, then it has an internal energy approximately given by
Even if the mathematical form of the ideal-gas constitutive relations is simple, their application can be extremely complex. These relations apply to very small control volumes, and if we want to accurately model a body of gas, we need to use a large number of them. This gives rise to many interesting behaviours, such as turbulence.

We consider their application in the following simplified setup:
\begin{itemize}[nosep]
\item Only one control volume is used. Two of its dimensions are fixed; and the third, say the vertical one, is variable. We can assume a cylindrical shape with constant base area $A$ and variable volume $V$.
\item test
\item test
\end{itemize}

\begin{definition}{Ideal-gas law}
If a small control volume $V$ contains an amount $\yN$ of matter, has temperature $\yte$, and there is no flux of matter through its surface, then the \textbf{pressure} $p$, that is, the momentum \textbf{ef}flux \emph{per unit area} through a small surface, has magnitude
\begin{equation}
\label{eq:ideal_gas_p}
p = \frac{R \yN \yte}{V} - \yvis \frac{1}{V}\frac{\di V}{\di t}
\end{equation}
where $\frac{\di V}{\di t}$ is the rate of change of volume and $\lambda$ is a \textbf{viscosity} coefficient.

\smallskip

If only one dimension of the volume is changing, then the coefficient $\yvis$ is given by
\begin{equation}
\label{eq:viscosity_gen}
\yvis = \frac{4}{3}\eta + \zeta
\end{equation}
where $\eta$ and $\zeta$ are called the \emph{shear} and \emph{bulk} \furl{https://www.britannica.com/science/fluid-mechanics/Viscosity}{viscosity coefficients}. These coefficients are always positive, and usually depend on the temperature.
\end{definition}
%
\marginpar{\vspace{0\baselineskip}\centering%
\includegraphics[width=\linewidth]{idealgas_mug.jpg}%
% \\[\jot]\footnotesize\flushleftright{\color{mpcolor}%
% The famous \enquote{$pV=NRT$} formula}%
}%
In the expression above you may recognize the famous \enquote{$pV=NRT$} formula, called the \textbf{ideal-gas law}. This famous formula is strictly speaking valid only valid when the ideal gas is at rest. If the ideal gas is in motion, for instance expanding or contracting, so that its volume $V$ changes with time, then additional terms must be added to the formula. The term above is valid only in particular cases.
Usually these additional terms are extremely small and therefore neglected.

The fact that the viscosity coefficients above must be positive is a consequence of the \emph{balance of entropy} -- the second law of thermodynamics -- which we shall discuss later.

\medskip

\begin{definition}{Internal energy of an ideal gas}
If a small control volume contains an amount of matter $\yN$ and has uniform temperature $\yte$, then it also contains an amount of internal energy $\yU$ equal to
\begin{equation}
\label{eq:int_energy_idealgas}
\yU = C\,\yN\,\yte
\end{equation}
where the constant $C$ depends on the kind of matter and is called
where the constant $C$ depends on the kind of matter and is called \emph{molar heat capacity}.
\end{definition}
This formula is very important: it says that, for an ideal gas, the absolute temperature is a direct measure of the internal energy, so it can often be used as a proxy for the latter.
\begin{warning}[Only valid for an ideal gas]
\begin{itemize}[shift]
\item Keep in mind that this particular relation between internal energy and temperature is valid for an ideal gas only. In general, the internal energy of a material depends on other quantities besides temperature.
\item The statement \enquote{depends only on temperature} must of course be understood correctly.
\end{itemize}
\end{warning}

\medskip

\begin{definition}{Fourier law}
Consider small control surface of area $A$, orthogonal to some direction, say the coordinate-$z$ direction. Then through this surface there is a heat flux $\yQ$ given by \textbf{Fourier's law of heat conduction}:
\begin{equation}
\label{eq:fourier_law}
\yQ = -A k \frac{\de\yte}{\de z}
\end{equation}
where $\frac{\de\yte}{\de z}$ tells how much the temperature $\yte$ differs along the $z$-direction, and $k$ is called the \furl{https://www.britannica.com/science/thermal-conductivity}{coefficient of thermal conductivity}. This coefficient is always positive, and usually depends on the temperature.
\end{definition}


Expand Down

0 comments on commit ec7ef4e

Please sign in to comment.