\section{Statistical postulates}
<<<<<<< HEAD
So far we have looked at the macroscopic properties of a thermodynamics system and at some ways of calculating properties of random processes that obey some given probability distribution. Now it is time to combine these ideas and have a first attempt at linking the microscopic behaviour of a thermodynamic system (an idealised gas) with some of its macroscopic properties.
=======
So far we have looked at the macroscopic properties of a thermodynamical system and at some ways of calculating properties of random processes that obey some given probability distribution. Now it is time to combine these ideas and have a first attempt at linking the microscopic behaviour of a thermodynamic system (an idealised gas) with some of its macroscopic properties.
>>>>>>> pr/2

The behaviour of a given (mechanical) system depends on both the structure of the system --- described by its equations of motion --- and on the \emph{initial conditions} of the system. Therefore, in order to describe the behaviour of the system, we need both the laws of mechanics for the system along with some statistical postulates about the initial conditions of the system. (We could also require that we know the exact initial conditions for all the particles in the system, but this is not realistic for $\mathcal{O}(10^{23})$ particles.) Different choices of the statistical postulates can lead to different behaviour (not just different states) of the system. We will look at Maxwell's postulates for the initial positions and velocities of a dilute collection of gas particles. We will see that they allow us to derive the ideal gas law from a microscopic basis.

\subsection{An ideal gas}
We want to keep the equations of motion for our system of particles as simple as possible. We are going to assume   that our system has the following properties:
\begin{itemize}
\item We have $N$ identical  point particles, each with mass $m$, constrained in a volume $V$.
\item There are no mutual interactions --- no van der Waals effects or inter-particle forces for us!
\item The walls of the container constraining the particles are perfectly reflecting.
\item The mechanical state of the system is known when the position $\bf r$ and velocity $\bf v$ is known for each particle and these variables evolve according to Newton's laws of motion.
\end{itemize}

\subsection{Maxwell's postulates}
We assume that the vectors describing the initial conditions of the system are randomly distributed. More specifically:
\begin{enumerate}
\item The vectors relating to each particle are independent from each other. (e.g. there is no interaction between particles when they are close.) This is generally not true for any but the most dilute systems. For such a non-interacting system, the system's state is determined when $dN=f({\bf r},{\bf v})$ is known, where $dN$ is the number of particles in a box with sides $d{\bf r}=(dx,dy,dz)$ centered on the point ${\bf r} = (x,y,z)$ and where the corresponding velocities of the particles lie within a box d${\bf v}=(dv_x,dv_y,dv_z)$ centered on ${\bf v}=(v_x,v_y,v_z)$. This relationship defines the \emph{single-particle distribution} $f({\bf r},{\bf v})$.
\item The positions ${\bf r}$ are independent of the velocities ${\bf v}$. This means we can factorise $f({\bf r},{\bf v})$ as $f({\bf r},{\bf v})$ =$f_r({\bf r})$ $f_v({\bf v})$ .
\item The density of the gas is uniform within the volume so we can write $f({\bf r}) = N/V=\rho=$ constant inside the volume (and zero outside it).
\item The velocity components are independent of each other so we can factorise $f_v$ as $f_v({\bf v})=f_x(v_x)f_y(v_y)f_z(v_z)$.
\item The distribution $f_v({\bf v})$ is isotropic in velocity space so that $f_v$ depends only on the magnitude of the velocity $|{\bf v}| = v$
\end{enumerate}

\subsection{Equation of state}
Maxwell's postulates allow us to derive the equation of state for an ideal gas (the ideal gas law). They provide a microscopic interpretation of absolute temperature in terms of kinetic energy.

Consider a particle with velocity ${\bf v} = (v_x,v_y,v_z)$, moving from the left, that hits a wall parallel to the $yz$-plane. After impact its velocity is ${\bf v'}=(-v_x,v_y,v_z)$. Hence, the change in momentum is $\Delta {\bf p}= {\bf p'} - {\bf p} = m({\bf v'}-{\bf v}) = m(-2v_x,0,0)$.

How many such impacts occur in a given time interval $\Delta t$ on a region of the wall with area $A$?
Take a box with a side of area $A$ on the wall and perpendicular sides of length $v_x\Delta t$. This contains the particles of velocity ${\bf v}$ that can hit the wall. The volume of the box is $Av_x\Delta t$ and the number of particles it contains is $\rho Av_x\Delta t f_v({\bf v})$, where $\rho=N/V$ is the density of all particles  and $f_v$ is the probability that a particle has velocity $\bf v$.
The total momentum $\Delta P$ transmitted to the wall is therefore
$$\Delta P =\int_0^\infty dv_x \int_{-\infty}^\infty dv_y \int_{-\infty}^\infty dv_z f_v({\bf v})\rho A\Delta t(-2m)v_x^2{\bf i}$$
where ${\bf i} =(1,0,0)$ picks out the $x$-component. I.e. integrate over the number of particles times the momentum per particle. The first integral only runs from zero since we are only interested in particles traveling towards the right, i.e. ${\bf v}>0$.

The integral above gives
$$\Delta P = -2m\rho A\Delta t \langle v_x^2\rangle\frac12$$ where the average square velocities come from integrating over the velocity distribution and the factor of half comes from the integral over $v_x$, i.e. particles moving towards the right.
The force exerted by the gas on the wall is $F=\Delta P/\Delta t$ and pressure is force/area = $|F|/A$.
We therefore have
\begin{equation}
	p=m\rho  \langle v_x^2\rangle.
	\label{eq1.2}
\end{equation}

Compare this with the classical equation of state for an ideal gas $pV=nRT$ where $n=N/N_A$, $T$ is temperature and $R=8.3 J/K$ is a constant. If we introduce the Boltzman constant $k_B = R/N_A$ and the particle density $\rho =n/V$. The ideal gas law becomes $p=\rho k_BT$. Comparing the ideal gas law with equation \ref{eq1.2}
we find that we can relate the absolute temperature $T$ to the mean square velocities of the particles.


\section{Implementation} % (fold)
\label{sec:implementation}
We decided to use the \textsc{Julia}
programming language as our coding partner.
Using \textsc{Julia} intuitive package generator, we were able to
produce beautiful documentation and we therefore invite
the reader to have a look at the \textsc{html} documentation located
in the folder \texttt{html\_doc/} by opening the \texttt{index.html} file.
The latter contains a structured presentation of the architecture
of our code as well as a description of each function.

Note also that we used \textsc{JuMP}, a modelling language (\cite{DunningHuchetteLubin2017}) for \textsc{Julia}, for the optimization models.
The models have been solved with the commercial solver \textsc{CPLEX} for which free academic licenses are available.
% section implementation (end)


\documentclass{article}

\usepackage{lipsum}

\usepackage{infoBulle}

\usepackage[%
	a4paper,
%	showframe,
	twoside,
	top=27mm,
	bottom=27mm,
	inner=20mm,
	outer=20mm,
	ignorehead,
	ignorefoot,
	ignoremp,
	marginparwidth=0mm,
	marginparsep=0mm,
	headsep=7mm,
	footskip=14mm,
	headheight=12.2pt,
]{geometry}
\setlength{\marginparpush}{\baselineskip}

\title{infoBulle Showcase}
\author{Harvey Sheppard}

\infoBulleConfiguration{icon/shape = hexagon}

\begin{document}

	\maketitle

	\section{Text InfoBulles}

	\infoInfo{\lipsum[2]}{\lipsum[2]}

	\questionInfo{Is this a question?}{\lipsum[2]}

	\checkInfo{What an Example}{\lipsum[2]}

	\warningInfo{Warning!}{\lipsum[2]\lipsum[2]}

	\criticalInfo{Critical Info!}{\lipsum[2]}

	\tipsInfo{Tips!}{\lipsum[2]}

	\begin{CodeInfo}{Some code!}[And a caption]
		\begin{CodeInfoLst}
#!/usr/bin/env python
print "Hello World"
		\end{CodeInfoLst}
		\lipsum[2]
	\end{CodeInfo}

	\section{Math InfoBulles}

	\begin{theorem}[Pythagoras]
		Assuming we have a rectangle triangle with the hypotenuse named c. Then:
		\[
		a^2 + b^2 = c^2
		\]
	\end{theorem}

	\begin{lemma}[Pythagoras]
		Assuming we have a rectangle triangle with the hypotenuse named c. Then:
		\[
		a^2 + b^2 = c^2
		\]
	\end{lemma}

	\begin{axiom}[Pythagoras]
		Assuming we have a rectangle triangle with the hypotenuse named c. Then:
		\[
		a^2 + b^2 = c^2
		\]
	\end{axiom}

	\begin{proposition}[Pythagoras]
		Assuming we have a rectangle triangle with the hypotenuse named c. Then:
		\[
		a^2 + b^2 = c^2
		\]
	\end{proposition}

	\begin{definition}[Pythagoras]
		Assuming we have a rectangle triangle with the hypotenuse named c. Then:
		\[
		a^2 + b^2 = c^2
		\]
	\end{definition}

	\begin{corollary}[Pythagoras]
		Assuming we have a rectangle triangle with the hypotenuse named c. Then:
		\[
		a^2 + b^2 = c^2
		\]
	\end{corollary}

\end{document}


\section{Discrete choice estimation with individual data}


\chapter{$\equiv_{p}$-characterization}
\label{ch:modular:characterization}

\input{Chapters/mod-p-characterization/previous-work.tex}

\input{Chapters/mod-p-characterization/pascal.tex}
\input{Chapters/mod-p-characterization/catalan.tex}


\section{Topology}

An {\tt ADCL\_Topology} objects contains the description of the process topology and neighborhood relations within the application. The reason ADCL introduces this abstraction and does not rely entirely on the MPI cartesian communicators is, that many codes have a multi-dimensional process distribution, where the process dimensions are running in a different order compared to a cartesion MPI communicator. Thus, ADCL provides a topology constructor using MPI cartesion communicators, but also a generic constructor, where the user can define for each process who its neighbors are.

\begin{verbatim}
int ADCL_Topology_create  ( MPI_Comm cart_comm,
    ADCL_Topology *topo);

subroutine ADCL_Topology_create ( cart_comm, topo, ierror )
integer cart_comm, topo, ierror
\end{verbatim}
with
\begin{itemize}
\item {\tt cart\_comm}(IN): MPI cartesian communicator. A call to {\tt MPI\_Topo\_test} has to return {\tt MPI\_CART} for {\tt cart\_comm} to be valid in this function call.
\item {\tt topo}(OUT): handle of an ADCL topology object.
\end{itemize}

\hspace{1cm}
\begin{verbatim}
int ADCL_Topology_create_generic ( int ndims, int *lneighbors,
    int *rneighbors, int *coords, int direction,
    MPI_Comm comm, ADCL_Topology *topo);

subroutine ADCL_Topology_create_generic ( ndims, lneighbors,
    rneighbors, coords, direction, comm, topo, ierror )
integer ndims, direction, comm, topo, ierror
integer lneighbors(*), rneighbors(*), coords(*)
\end{verbatim}
with
\begin{itemize}
\item {\tt ndims}(IN): number of dimensions of the process topology.
\item {\tt lneighbors}(IN): integer array of dimension {\tt ndims} containing the ranks
	of the left neighbors for each dimension. In case a left neighbor does not exist (e.g. the
	process is at the boundary of the process topology), the according entry in the array
	has to be set to {\tt MPI\_PROC\_NULL}.
\item {\tt rneighbors}(IN): integer array of dimension {\tt ndims} containing the ranks
	of the right neighbors for each dimension. In case a right neighbor does not exist (e.g. the
	process is at the boundary of the process topology), the according entry in the array
	has to be set to {\tt MPI\_PROC\_NULL}.
\item {\tt coords}(IN): integer array of dimension {\tt ndims} containing the coordinates
  of the process in the process topology.
\item {\tt direction}(IN): ?
\item {\tt comm}(IN): valid MPI communicator. In contrary to the previous function, this does not
 have to be an MPI cartesian communicator.
\item {\tt topo}(OUT): handle of an ADCL topology object.
\end{itemize}

\hspace{1cm}
\begin{verbatim}
int ADCL_Topology_free ( ADCL_Topology *topo );
\end{verbatim}
with
\begin{itemize}
\item {\tt topo}(INOUT): ADCL topology object to be released. Upon successful completion, the handle will be set to {\tt ADCL\_TOPOLOGY\_NULL}.
\end{itemize}

\subsection{Example}

The following example shows how to register a 2-D process topology with ADCL for an arbitrary number of processes using MPI cartesian communicators.

\begin{verbatim}
#include <stdio.h>
#include "ADCL.h"
#include "mpi.h"

int main ( int argc, char ** argv )
{
    MPI_Comm cart_comm;
    ADCL_Topology topo;
    int cdims[]={0,0}, periods[]={0,0};

    MPI_Init ( &argc, &argv );
    ADCL_Init ();

    MPI_Dims_create ( size, 2, cdims );
    MPI_Cart_create ( MPI_COMM_WORLD, 2, cdims, periods, 0,
                      &cart_comm);
    ADCL_Topology_create ( cart_comm, &topo );

 	  /* do something useful with the topology object */

    ADCL_Topology_free ( &topo );
    MPI_Comm_free ( &cart_comm );

    ADCL_Finalize ();
    MPI_Finalize ();
    return 0;
}
\end{verbatim}


\documentclass{article}
\usepackage[english]{babel}
\usepackage[]{amsthm} %lets us use \begin{proof}
\usepackage[]{amssymb} %gives us the character \varnothing
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[font={small,it}]{caption}

\title{Perspective Correct Interpolation of Vertex Attributes}
\author{Samuel S. Egger}
\date\today
%This information doesn't actually show up on your document unless you use the maketitle command below

\begin{document}
\maketitle %This command prints the title based on information entered above

%Section and subsection automatically number unless you put the asterisk next to them.
\section*{Texture Mapping}
Texture mapping can roughly be summarized as the process of mapping an image onto the surface of an object in three-dimensional Euclidean space (we will from now on refer to this space as camera space). The texture mapping happens in the rasterization stage of the graphics pipeline after a scene from camera space has been projected onto a plane ($z=-d$). We call this plane the image plane.

In order to rasterize a triangular polygon from the image plane onto the screen, we first transform its vertices into screen space (or pixel space) and for each pixel inside the polygon we determine its color. When using a texture, we lookup the pixels color in that texture.

\subsection*{$z$-Interpolation}

\begin{figure}[!ht]
    \centering
    \def\svgwidth{80mm}
    \input{drawing.pdf_tex}
    \caption{Sideview (facing down the negative $x$-axis) of a triangle being projected onto the image plane}
    \label{fig:aufbau}
\end{figure}

Let there be an edge in camera space that goes from $p'$ to $p''$. During rasterization we only know the depth value $z$ for $q'$ and $q''$. For each pixel position $q$ we have to somehow figure out the corresponding depth value.

The $z$-value for $p$ can by determined by a simple linear interpolation using the equation \[p_{z}=p'_{z}+\alpha(p''_{z}-p_{z}')\textrm{.}\]

However, we want to know $p_{z}$ as a function of $q_{x}$, that is \[z = f(x)\;  \textrm{for}\;x\in{[q'_{x},\,q''_{x}]}\textrm{.}\]

For that in turn we need to figure out what $\alpha$ is in terms of $q$. In terms of $p$, $\alpha$ is given by the equation

\[\alpha=\frac{p_{z}-p'_{z}}{p''_{z}-p'_{z}}\textrm{.}\]

\end{document}