Skip to content
Snippets Groups Projects
Commit f70fbdc5 authored by Ruben Heinrich's avatar Ruben Heinrich
Browse files

[docs] included ensemble for logarithmic slope

parent 3bf1ea6e
No related branches found
No related tags found
1 merge request!14Resolve "edit vignette for theis problem"
...@@ -9,11 +9,12 @@ vignette: > ...@@ -9,11 +9,12 @@ vignette: >
```{r, include = FALSE} ```{r, include = FALSE}
knitr::opts_chunk$set( knitr::opts_chunk$set(
eval = nzchar(Sys.getenv("r2ogs6_ensemble_guide_eval")),
fig.width = 6, fig.width = 6,
fig.align = "center", fig.align = "center",
collapse = TRUE, collapse = TRUE,
comment = "#>", comment = "#>",
message = FALSE message = FALSE,
) )
devtools::load_all(".") devtools::load_all(".")
...@@ -55,7 +56,7 @@ First, we create a simulation object to base our ensemble on and read in the `.p ...@@ -55,7 +56,7 @@ First, we create a simulation object to base our ensemble on and read in the `.p
```{r} ```{r}
# Change this to fit your system # Change this to fit your system
testdir_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6") testdir_path <- system.file("extdata/test_tempdirs", package = "r2ogs6")
sim_path <- paste0(testdir_path, "/axisym_theis_sim") sim_path <- paste0(testdir_path, "/axisym_theis_sim")
ogs6_obj <- OGS6$new(sim_name = "axisym_theis", ogs6_obj <- OGS6$new(sim_name = "axisym_theis",
...@@ -227,7 +228,7 @@ First, we create a simulation object to base our ensemble on and read in the `.p ...@@ -227,7 +228,7 @@ First, we create a simulation object to base our ensemble on and read in the `.p
```{r} ```{r}
# Change this to fit your system # Change this to fit your system
testdir_path <- system.file("extdata/test_tempdirs/", package = "r2ogs6") testdir_path <- system.file("extdata/test_tempdirs", package = "r2ogs6")
sim_path <- paste0(testdir_path, "/theis_sim") sim_path <- paste0(testdir_path, "/theis_sim")
ogs6_obj <- OGS6$new(sim_name = "theis", ogs6_obj <- OGS6$new(sim_name = "theis",
...@@ -273,19 +274,25 @@ When the simulations have run, we can extract and plot the results like before. ...@@ -273,19 +274,25 @@ When the simulations have run, we can extract and plot the results like before.
```{r} ```{r}
# Extract point ids # Extract point ids
all_points <- ogs6_ens_theis_2$ensemble[[1]]$pvds[[1]]$OGS6_vtus[[1]]$points get_point_ids_x <- function(points){
x_axis_ids <- numeric() x_axis_ids <- numeric()
for(i in seq_len(dim(all_points)[[1]])){ for(i in seq_len(dim(points)[[1]])) {
if(all_points[i,][[2]] == 0 && all_points[i,][[3]] == 0){ if (points[i, ][[2]] == 0 && points[i, ][[3]] == 0) {
x_axis_ids <- c(x_axis_ids, (i-1)) x_axis_ids <- c(x_axis_ids, (i - 1))
}
} }
return(x_axis_ids)
} }
point_ids_x <- get_point_ids_x(
ogs6_ens_theis_2$ensemble[[1]]$pvds[[1]]$OGS6_vtus[[1]]$points)
# Get combined dataframe # Get combined dataframe
per_por_slo_df <- per_por_slo_df <-
ogs6_ens_theis_2$get_point_data( ogs6_ens_theis_2$get_point_data(
point_ids = x_axis_ids, point_ids = point_ids_x,
keys = c("pressure"), keys = c("pressure"),
start_at_timestep = ogs6_ens_theis_2$ensemble[[1]]$pvds[[1]]$last_timestep) start_at_timestep = ogs6_ens_theis_2$ensemble[[1]]$pvds[[1]]$last_timestep)
``` ```
...@@ -317,6 +324,67 @@ ggplot(per_df, ...@@ -317,6 +324,67 @@ ggplot(per_df,
labs(color = "%") labs(color = "%")
``` ```
Maybe we want to try and use a logarithmic approach for `slope`. This won't work with the built-in functionality of `OGS6_Ensemble` so we'll set up our Ensemble a little differently.
```{r}
# Calculate log value
log_val <- log(as.numeric(
ogs6_obj$media[[1]]$phases[[1]]$properties[[1]]$independent_variable[[2]]$slope),
base = 10)
# Apply changes to log value
log_vals <- vapply(percentages, function(x){
log_val + (log_val * (x / 100))
}, FUN.VALUE = numeric(1))
# Transfer back to non-logarithmic scale
back_transf_vals <- 10^log_vals
# Set up new ensemble
ogs6_ens_slo <-
OGS6_Ensemble$new(
ogs6_obj = ogs6_obj,
parameters =
list(
slo = list(
ogs6_obj$media[[1]]$phases[[1]]$properties[[1]]$independent_variable[[2]]$slope,
values = back_transf_vals)
),
percentages_mode = FALSE,
sequential_mode = TRUE
)
exit_codes <- ogs6_ens_slo$run_simulation()
```
Let's check if we can observe any influence of `slope` on `pressure` now.
```{r}
# Filter point ids
point_ids_x <- get_point_ids_x(
ogs6_ens_slo$ensemble[[1]]$pvds[[1]]$OGS6_vtus[[1]]$points)
# Get combined dataframe
slo_df <-
ogs6_ens_slo$get_point_data(
point_ids = point_ids_x,
keys = c("pressure"),
start_at_timestep = ogs6_ens_slo$ensemble[[1]]$pvds[[1]]$last_timestep)
# Supply percentages manually since we couldn't use `percentages_mode`
percs <- vapply(slo_df$sim_id,
function(x){percentages[[x]]},
FUN.VALUE = numeric(1))
ggplot(slo_df,
aes(x = x,
y = pressure)) +
geom_point(aes(color = as.factor(percs))) +
xlab("x point coordinate") +
labs(color = "%")
```
## Summary ## Summary
The `OGS6_Ensemble` class is a useful tool to set up ensemble runs for sensitivity analyses. In this vignette, we learned how to create `OGS6_Ensemble` objects. We looked at how the parameters `sequential_mode` and `percentages_mode` influence how our ensemble object is initialised. We started simulations via `OGS6_Ensemble$run_simulation()` and extracted information from the output files to plot them. The `OGS6_Ensemble` class is a useful tool to set up ensemble runs for sensitivity analyses. In this vignette, we learned how to create `OGS6_Ensemble` objects. We looked at how the parameters `sequential_mode` and `percentages_mode` influence how our ensemble object is initialised. We started simulations via `OGS6_Ensemble$run_simulation()` and extracted information from the output files to plot them.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment