arma-thesis

git clone https://git.igankevich.com/arma-thesis.git
Log | Files | Refs | LICENSE

commit 0ef9819eb98cc1a1523ea0eb209272f8b47c6f62
parent a19c6c376f0e859bfb77dc445af7d945f01c8b00
Author: Ivan Gankevich <igankevich@ya.ru>
Date:   Wed,  5 Apr 2017 19:59:14 +0300

Add R velocity plot.

Diffstat:
R/velocity-potentials.R | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
arma-thesis.org | 17+++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/R/velocity-potentials.R b/R/velocity-potentials.R @@ -0,0 +1,52 @@ +arma.middle_element <- function (x) { + x[round(length(x) + 0.5)/2] +} + +arma.plot_velocity_potential_field <- function (dir, ...) { + args <- list(...) + phi <- read.csv(file.path(dir, 'phi.csv')) + left_top_x <- 0.1 + right_top_x <- max(phi$x) + # slice time and Y ranges through the center + slice_t <- arma.middle_element(unique(phi$t)) + slice_y <- arma.middle_element(unique(phi$y)) + print(paste('Middle elements (TY) = ', slice_t, slice_y)) + phi_slice <- phi[phi$t == slice_t & phi$y == slice_y & phi$x >= left_top_x & phi$z >= -8,] + x <- unique(phi_slice$x) + z <- unique(phi_slice$z) + left_top_z <- max(phi_slice$z) + right_top_z <- left_top_z + print(paste('Velocity field size (XZ) = ', length(x), length(z))) + + # convert data frame to matrix + seq_x <- seq_along(x) + seq_z <- seq_along(z) + indices <- data.matrix(expand.grid(seq_x, seq_z)) + u <- with(phi_slice, { + out <- matrix(nrow=length(seq_x), ncol=length(seq_z)) + out[indices] <- phi + out + }) + #summary(u) + + # get wave profile + zeta <- read.csv(file.path(dir, 'zeta.csv')) + zeta_slice <- zeta[zeta$t == slice_t & zeta$y == slice_y & zeta$x >= left_top_x,] + + #phi_range <- range(phi_slice[phi_slice$z <= zeta_slice$z, "phi"]) + + contour( + x, z, u, levels=args$levels, + asp=1, + drawlabels=FALSE + # color.palette=colorRampPalette( c("blue", "white", "red") ) + ) + + top_area_x <- c(left_top_x*0.99, zeta_slice$x, right_top_x*1.01) + top_area_z <- c(left_top_z*1.10, zeta_slice$z, right_top_z*1.10) + polygon(top_area_x, top_area_z, lwd=4, border=NA, col='white') + lines(zeta_slice$x, zeta_slice$z, lwd=4) + #image(x, z, u, c(-2,2), col=heat.colors(128)) + box() + title(xlab="x", ylab="z") +} diff --git a/arma-thesis.org b/arma-thesis.org @@ -2030,6 +2030,23 @@ experiment, in which all terms of eqref:eq-solution-2d-full that are neglected in the framework of linear wave theory are eliminated, shows no difference (as much as machine precision allows) in resulting velocity potential fields. +#+begin_src R :file build/plain-wave-linear-solver.pdf +source(file.path("R", "velocity-potentials.R")) +par(pty="s", mfrow=c(1, 2)) +lvls=pretty(c(-200,200), 20) +arma.plot_velocity_potential_field( + file.path("build", "plain_wave_linear_solver"), + levels=lvls +) +arma.plot_velocity_potential_field( + file.path("build", "plain_wave_high_amplitude_solver"), + levels=lvls +) +#+end_src + +#+RESULTS: +[[file:build/plain-wave-linear-solver.pdf]] + #+name: fig-potential-field-nonlinear #+caption: Velocity potential field of propagating wave \(\zeta(x,y,t) = \cos(2\pi x - t/2)\). Field produced by formula eqref:eq-solution-2d-full (top) and linear wave theory formula (bottom). #+begin_figure