Add continuum mechanics' P4 lab session

Change-Id: I15a80d28235451f82743b553044662dd66876764
diff --git a/quad8/continuummechanics/lab/.gitignore b/quad8/continuummechanics/lab/.gitignore
new file mode 100644
index 0000000..19d0629
--- /dev/null
+++ b/quad8/continuummechanics/lab/.gitignore
@@ -0,0 +1,2 @@
+# Don't include compiled PDFs
+*.pdf
diff --git a/quad8/continuummechanics/lab/p4/.gitignore b/quad8/continuummechanics/lab/p4/.gitignore
new file mode 100644
index 0000000..53752db
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/.gitignore
@@ -0,0 +1 @@
+output
diff --git a/quad8/continuummechanics/lab/p4/data/regresio.dat b/quad8/continuummechanics/lab/p4/data/regresio.dat
new file mode 100644
index 0000000..70781da
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/data/regresio.dat
@@ -0,0 +1,10 @@
+0.6	0.55495
+0.5652173913	0.54695
+0.5238095238	0.501
+0.4736842105	0.4008
+0.4117647059	0.38045
+0.3333333333	0.33385
+0.2857142857	0.2607
+0.2307692308	0.20705
+0.1666666667	0.17075
+0.09090909091	0.09875
diff --git a/quad8/continuummechanics/lab/p4/data/ws_vs_qs.dat b/quad8/continuummechanics/lab/p4/data/ws_vs_qs.dat
new file mode 100644
index 0000000..73ee4aa
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/data/ws_vs_qs.dat
@@ -0,0 +1,10 @@
+110.99 15
+109.39 13
+100.2 11
+80.16 9
+76.09 7
+66.77 5
+52.14 4
+41.41 3
+34.15 2
+19.75 1
diff --git a/quad8/continuummechanics/lab/p4/graph/graph.gnu b/quad8/continuummechanics/lab/p4/graph/graph.gnu
new file mode 100755
index 0000000..0f78491
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/graph/graph.gnu
@@ -0,0 +1,51 @@
+#!/usr/bin/env gnuplot -c
+outputfile="../output/graph"
+datafile="../data/regresio.dat"
+
+# == CONFIGURACIÓ DE L'OUTPUT PEL LATEX ==
+set terminal cairolatex size 11cm, 8cm
+set output outputfile.'.tex'
+
+# == CONFIGURACIÓ DEL PLOT ==
+set xlabel '$\frac{Q_s}{Q_s + Q_f}$'
+set ylabel '$\frac{w_s}{w}$'
+
+# Opcions per la llegenda:
+set key above
+set key spacing 1.5
+
+# == FIT ==
+set fit quiet
+
+# Funció per obtenir els dígits significatius d'una expressió
+f_sd(n, i) = (int(n) == 0 ? f_sd(n*10, i+1) : (int(n) == 1 ? i+1 : i))
+significant_digits(n) = f_sd(n - 10*int(n/10), 0)
+
+significant_digits_r(n) = (n == 1 ? 0 : significant_digits(1 - abs(n)))
+
+f(x) = a*x + b
+fit f(x) datafile u 1:2 via a, b
+stats datafile u 1:2 name "STATS" nooutput
+error_a = STATS_slope_err
+sd_error_a = significant_digits(error_a)
+error_b = STATS_slope_err
+sd_error_b = significant_digits(error_b)
+r = STATS_correlation
+sd_r = significant_digits_r(r)
+title_f(a, b, r) = sprintf('$\frac{Q_s}{Q_s + Q_f}(\frac{w_s}{w}) = %.'.sd_error_a.'f \frac{w_s}{w} + %.'.sd_error_b.'f$, $r = %.'.sd_r.'f$', a, b, r);
+
+print(sprintf('delta(a) = %.'.sd_error_a.'f, sd=%.0f', error_a, sd_error_a))
+print(sprintf('delta(b) = %.'.sd_error_b.'f, sd=%.0f', error_b, sd_error_b))
+print(sprintf('r = %.'.sd_r.'f, sd=%.0f', r, sd_r))
+
+plot datafile u 1:2 t "Dades", \
+     f(x) t title_f(a, b, r)
+
+# == CONFIGURACIÓ DE L'OUTPUT PER SVG ==
+# Això ho uso per generar també una imatge de previsualització que puc carregar
+# a l'ordinador per veure més o menys com a sortit el plot sense haver
+# d'inserir-ho al LaTeX per veure-ho.
+set terminal svg dashed size 600, 600 font "Computer Modern,Tinos,Helvetica,15"
+set output outputfile.'.svg'
+
+replot
diff --git a/quad8/continuummechanics/lab/p4/img/difusion_0_1_0_1_0_1.jpg b/quad8/continuummechanics/lab/p4/img/difusion_0_1_0_1_0_1.jpg
new file mode 100644
index 0000000..7d8ed43
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/difusion_0_1_0_1_0_1.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/difusion_0_1_0_1_0_1_tub.jpg b/quad8/continuummechanics/lab/p4/img/difusion_0_1_0_1_0_1_tub.jpg
new file mode 100644
index 0000000..9373374
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/difusion_0_1_0_1_0_1_tub.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/difusion_10_10_10.jpg b/quad8/continuummechanics/lab/p4/img/difusion_10_10_10.jpg
new file mode 100644
index 0000000..23880fb
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/difusion_10_10_10.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/difusion_10_10_10_tub.jpg b/quad8/continuummechanics/lab/p4/img/difusion_10_10_10_tub.jpg
new file mode 100644
index 0000000..5c504b5
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/difusion_10_10_10_tub.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/difusion_1_1_1.jpg b/quad8/continuummechanics/lab/p4/img/difusion_1_1_1.jpg
new file mode 100644
index 0000000..08b7d95
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/difusion_1_1_1.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/difusion_1_1_1_tub.jpg b/quad8/continuummechanics/lab/p4/img/difusion_1_1_1_tub.jpg
new file mode 100644
index 0000000..0e2dd9e
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/difusion_1_1_1_tub.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/finalphoto.bmp b/quad8/continuummechanics/lab/p4/img/finalphoto.bmp
new file mode 100644
index 0000000..2b52979
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/finalphoto.bmp
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/finalphoto.png b/quad8/continuummechanics/lab/p4/img/finalphoto.png
new file mode 100644
index 0000000..64962a7
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/finalphoto.png
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/parte2_1+.jpg b/quad8/continuummechanics/lab/p4/img/parte2_1+.jpg
new file mode 100644
index 0000000..a4fdc79
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/parte2_1+.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/parte2_13.jpg b/quad8/continuummechanics/lab/p4/img/parte2_13.jpg
new file mode 100644
index 0000000..7e1c609
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/parte2_13.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/parte2_15.jpg b/quad8/continuummechanics/lab/p4/img/parte2_15.jpg
new file mode 100644
index 0000000..3c8e8be
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/parte2_15.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/parte2_2.jpg b/quad8/continuummechanics/lab/p4/img/parte2_2.jpg
new file mode 100644
index 0000000..758fdfb
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/parte2_2.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/parte2_4.jpg b/quad8/continuummechanics/lab/p4/img/parte2_4.jpg
new file mode 100644
index 0000000..50322b1
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/parte2_4.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/img/parte2_7.jpg b/quad8/continuummechanics/lab/p4/img/parte2_7.jpg
new file mode 100644
index 0000000..e6f31aa
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/img/parte2_7.jpg
Binary files differ
diff --git a/quad8/continuummechanics/lab/p4/informe/p4.tex b/quad8/continuummechanics/lab/p4/informe/p4.tex
new file mode 100644
index 0000000..e42c6fc
--- /dev/null
+++ b/quad8/continuummechanics/lab/p4/informe/p4.tex
@@ -0,0 +1,140 @@
+\documentclass[11pt,a4paper]{article}
+\usepackage[utf8]{inputenc}
+\usepackage[catalan]{babel}
+\usepackage{fancyhdr}
+\usepackage{graphicx}
+\usepackage[labelfont=bf]{caption}
+\usepackage{siunitx}
+\usepackage{geometry}
+\geometry{margin=20mm}
+\usepackage{amsmath}
+\usepackage{amsfonts}
+\usepackage{booktabs}
+\usepackage{chemformula}
+\usepackage{multicol}
+\usepackage{hyperref}
+
+\usepackage{pgfplotstable}
+\pgfplotsset{compat=1.16}
+\pgfplotstableset{
+empty cells with={--}, % replace empty cells with ’--’
+every head row/.style={before row=\toprule,after row=\midrule},
+every last row/.style={after row=\bottomrule},
+set thousands separator={\,}%,
+%every even row/.style={
+%before row={\rowcolor[gray]{0.9}}}, % Add this for stylish tables ;)
+%begin table=\begin{longtable},
+%end table=\end{longtable}
+}
+
+\sisetup{separate-uncertainty=true}
+
+\setlength{\parskip}{1em}
+
+\pagestyle{fancy}
+\fancyhf{}
+\rhead{Adrià Vilanova Martínez}
+\lhead{Práctica 4}
+\rfoot{\thepage}
+
+%%%% Title %%%%
+\title{\vspace{-2ex}Práctica 4. Introducción a la microfluídica}
+\author{Adrià Vilanova Martínez (D1)\vspace{-2ex} }
+\date{Primavera curso 2020-21}
+
+\begin{document}
+  \maketitle
+
+  \section{Medida del efecto de la difusión y estimación del coeficiente de difusión}
+
+  \begin{center}
+    \begin{minipage}{\textwidth}
+      \begin{multicols}{2}
+        \begin{center}
+          \centering
+          \includegraphics[width=\columnwidth]{../img/difusion_10_10_10.jpg}
+          \captionof{figure}{Imagen en la intersección de los canales para un caudal de entrada en los 3 microcanales de $\SI{10}{\meter\per\second}$.}
+        \end{center}
+
+        \begin{center}
+          \centering
+          \includegraphics[width=\columnwidth]{../img/difusion_10_10_10_tub.jpg}
+          \captionof{figure}{Imagen del canal de salida para un caudal de entrada en los 3 microcanales de $\SI{10}{\meter\per\second}$.}
+        \end{center}
+      \end{multicols}
+    \end{minipage}
+  \end{center}
+
+  \begin{center}
+    \begin{minipage}{\textwidth}
+      \begin{multicols}{2}
+        \begin{center}
+          \centering
+          \includegraphics[width=\columnwidth]{../img/difusion_1_1_1.jpg}
+          \captionof{figure}{Imagen en la intersección de los canales para un caudal de entrada en los 3 microcanales de $\SI{1}{\meter\per\second}$.}
+        \end{center}
+
+        \begin{center}
+          \centering
+          \includegraphics[width=\columnwidth]{../img/difusion_1_1_1_tub.jpg}
+          \captionof{figure}{Imagen del canal de salida para un caudal de entrada en los 3 microcanales de $\SI{1}{\meter\per\second}$.}
+        \end{center}
+      \end{multicols}
+    \end{minipage}
+  \end{center}
+
+  \begin{center}
+    \begin{minipage}{\textwidth}
+      \begin{multicols}{2}
+        \begin{center}
+          \centering
+          \includegraphics[width=\columnwidth]{../img/difusion_0_1_0_1_0_1.jpg}
+          \captionof{figure}{Imagen en la intersección de los canales para un caudal de entrada en los 3 microcanales de $\SI{0.1}{\meter\per\second}$.}
+        \end{center}
+
+        \begin{center}
+          \centering
+          \includegraphics[width=\columnwidth]{../img/difusion_0_1_0_1_0_1_tub.jpg}
+          \captionof{figure}{Imagen del canal de salida para un caudal de entrada en los 3 microcanales de $\SI{0.1}{\meter\per\second}$.}
+        \end{center}
+      \end{multicols}
+    \end{minipage}
+  \end{center}
+
+  \section{Control de la anchura de focalización}
+
+  \begin{center}
+    \centering
+    \pgfplotstabletypeset[
+      columns/0/.style={column name=$w_s \, (\si{\micro\meter})$},
+      columns/1/.style={column name=$Q_s \, (\si{\micro\liter\per\minute})$}
+    ]{../data/ws_vs_qs.dat}
+    \captionof{table}{Datos experimentales de la anchura del canal central $w_s$ vs. el caudal del canal central $Q_s$.}
+  \end{center}
+
+  \begin{center}
+    \centering
+    \input{../output/graph.tex}
+    \captionof{figure}{Regresión realizada para obtener el valor de $g(1)$.}
+  \end{center}
+
+  Sabiendo que en nuestro caso $\lambda = 1$, podemos encontrar el valor de $g(\lambda)$ teórico sustituyendo ese valor en la fórmula teórica para $g(\lambda)$:
+  \[ g(1)_{\text{teórico}} = \left[ (1 + \lambda^2)(1 - 1.3553 \lambda + 1.9467 \lambda^2 - 1.7012 \lambda^3 + 0.9564 \lambda^4 - 0.2537 \lambda^5) \right]_{\lambda = 1} = 1.1858. \]
+
+  El valor experimental que hemos encontrado a partir de la regresión es:
+  \[ g(1)_{\text{experimental}} = \frac{1}{\text{pendiente recta}} = \SI{1.10(7)}{} \]
+
+  La discrepancia relativa entre el valor teórico i el experimental es:
+  \[ D = \frac{| g(1)_{\text{experimental}} - g(1)_{\text{teórico}} |}{|g(1)_{\text{teórico}}|} \approx 0.07 \]
+
+  Si queremos calcular el caudal necesario para obtener una anchura central de $\SI{10}{\micro\meter}$, es suficiente con usar la relación teórica (que hemos verificado experimentalmente)
+  \[ \frac{w_s}{w} = \frac{1}{g(\lambda)} \frac{Q_s}{Q_s + Q_f}, \]
+  donde hemos usado la $g(\lambda)$ teórica para ser más precisos:
+  \[ Q_s = \frac{w_s Q_f}{\frac{w}{g(1)} - w_s} = \SI{0.63}{\micro\liter\per\minute}. \]
+
+  \begin{center}
+    \centering
+    \includegraphics[width=\textwidth]{../img/finalphoto.png}
+    \captionof{figure}{Imagen donde se muestra que la anchura del canal es de $\SI{10}{\micro\meter}$ al usar un caudal de $\SI{0.63}{\micro\liter\per\minute}$.}
+  \end{center}
+\end{document}