Lab moderna: add p4
Change-Id: I56673d05625f628fbb33acfad3b482e3158cbb42
diff --git a/quad12/labmoderna/p4a/dades/dades.txt b/quad12/labmoderna/p4a/dades/dades.txt
new file mode 100644
index 0000000..b199a24
--- /dev/null
+++ b/quad12/labmoderna/p4a/dades/dades.txt
@@ -0,0 +1,10 @@
+Absorbent GruixMassic IntensitatReal
+14 324.2 30.80833333
+14 324.2 30.89
+12 216.2 56.15
+10 94.6 83.40
+8 43.2 106.20
+7 31.1 113.01
+6 25.7 113.86
+0 0 123.59
+
diff --git a/quad12/labmoderna/p4a/output/.gitignore b/quad12/labmoderna/p4a/output/.gitignore
new file mode 100644
index 0000000..e9575a3
--- /dev/null
+++ b/quad12/labmoderna/p4a/output/.gitignore
@@ -0,0 +1,3 @@
+*.png
+*.svg
+*.pdf
diff --git a/quad12/labmoderna/p4a/r/main.r b/quad12/labmoderna/p4a/r/main.r
new file mode 100644
index 0000000..41f7560
--- /dev/null
+++ b/quad12/labmoderna/p4a/r/main.r
@@ -0,0 +1,10 @@
+table <- read.table('dades/dades.txt', sep="\t", dec='.', header=TRUE)
+table$LogIntensitatReal <- log(table$IntensitatReal)
+
+fit <- lm(LogIntensitatReal~GruixMassic, data = table)
+summary(fit)
+
+svg(file='output/p1a.svg', width=6, height=5)
+plot(table$GruixMassic, table$LogIntensitatReal, xlab="Gruix màssic (mg/cm^2)", ylab="log(Intensitat · s)")
+abline(fit, col = "mediumorchid2")
+dev.off()
diff --git a/quad12/labmoderna/p4b/dades/dades.txt b/quad12/labmoderna/p4b/dades/dades.txt
new file mode 100644
index 0000000..1ba0141
--- /dev/null
+++ b/quad12/labmoderna/p4b/dades/dades.txt
@@ -0,0 +1,24 @@
+CampMagnetic IntensitatReal
+20 2.722222222
+40 6.622222222
+50 8.042222222
+55 9.112222222
+60 9.642222222
+62.5 10.31222222
+65 10.35222222
+67.5 10.08222222
+70 10.19222222
+72.5 10.40222222
+75 10.68222222
+77.5 10.74222222
+80 10.23222222
+82.5 10.09222222
+85 10.33222222
+87.5 9.812222222
+90 9.722222222
+95 9.512222222
+100 9.032222222
+105 8.552222222
+110 7.972222222
+120 6.512222222
+140 4.292222222
diff --git a/quad12/labmoderna/p4b/output/.gitignore b/quad12/labmoderna/p4b/output/.gitignore
new file mode 100644
index 0000000..e9575a3
--- /dev/null
+++ b/quad12/labmoderna/p4b/output/.gitignore
@@ -0,0 +1,3 @@
+*.png
+*.svg
+*.pdf
diff --git a/quad12/labmoderna/p4b/r/main.r b/quad12/labmoderna/p4b/r/main.r
new file mode 100644
index 0000000..5d079db
--- /dev/null
+++ b/quad12/labmoderna/p4b/r/main.r
@@ -0,0 +1,29 @@
+mec2 <- 510.999
+r <- 0.05
+ee <- 1.60e-19
+c <- 299792348
+eV <- 6.24e18
+
+table <- read.table('dades/dades.txt', sep="\t", dec='.', header=TRUE)
+table$LogIntensitatReal <- log(table$IntensitatReal)
+table$CampMagneticSq <- table$CampMagnetic^2
+table$E <- (sqrt((ee*c*(table$CampMagnetic/1000)*r*eV/1000)^2 + mec2^2) - mec2)/1000
+table$ESq <- table$E^2
+
+tablefit <- table[8:17,]
+
+fit <- lm(IntensitatReal ~ E + ESq, data = tablefit)
+summary(fit)
+fit_coef <- coef(fit)
+
+svg(file='output/p1b.svg', width=6, height=5)
+plot(table$E, table$IntensitatReal, xlab="Energia (MeV)", ylab="Intensitat (s^-1)")
+curve(fit_coef[1] + fit_coef[2]*x + fit_coef[3]*x*x, col = "mediumorchid2", add = TRUE)
+dev.off()
+
+svg(file='output/p1b2.svg', width=6, height=5)
+plot(table$CampMagnetic, table$E, xlab="Camp magnètic (mT)", ylab="Energia (MeV)")
+dev.off()
+
+Emax <- -fit_coef[2]/(2*fit_coef[3])
+Emax