Commit 39cbc064 authored by Johannes Boog's avatar Johannes Boog
Browse files

Merge branch '65-feat_dvalue_mediaproperty' into 'master'

Resolve "New element "dvalue" in "media/medium/properties/property""

Closes #65

See merge request !46
parents add3bfa9 130da3fb
Pipeline #13454 canceled with stage
in 2047 minutes and 53 seconds
......@@ -422,7 +422,7 @@ get_valid_phase_types <- function(){
#' @param exponents Optional:
#' @param lower_saturation_limit Optional:
#' @param upper_saturation_limit Optional:
#' @param ... independent_variable
#' @param ... independent_variable, dvalue
#' @example man/examples/ex_prj_ph_property.R
#' @export
prj_ph_property <- function(name,
......@@ -453,10 +453,12 @@ prj_ph_property <- function(name,
ellipsis_list <- list(...)
independent_variable <-
ellipsis_list[names(ellipsis_list) == "independent_variable"]
dvalue <- ellipsis_list[names(ellipsis_list) == "dvalue"]
new_prj_ph_property(name,
type,
value,
dvalue,
reference_value,
independent_variable,
offset,
......@@ -472,6 +474,7 @@ prj_ph_property <- function(name,
new_prj_ph_property <- function(name,
type,
value = NULL,
dvalue = NULL,
reference_value = NULL,
independent_variable = NULL,
offset = NULL,
......@@ -491,6 +494,14 @@ new_prj_ph_property <- function(name,
are_null_or_numeric(value)
}
if (!is.null(dvalue)) {
dvalue <- lapply(dvalue, function(x){
are_null_or_strings(x[[1]])
x[[2]] <- coerce_string_to_numeric(x[[2]])
return(x)
})
}
are_null_or_numbers(
reference_value,
offset,
......@@ -522,6 +533,7 @@ new_prj_ph_property <- function(name,
structure(list(name = name,
type = type,
value = value,
dvalue = dvalue,
reference_value = reference_value,
independent_variable = independent_variable,
offset = offset,
......@@ -535,7 +547,7 @@ new_prj_ph_property <- function(name,
attr_names = character(),
flatten_on_exp = c("exponents",
"swelling_pressures"),
unwrap_on_exp = c("independent_variable")
unwrap_on_exp = c("independent_variable", "dvalue")
),
class = "prj_ph_property"
)
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<OpenGeoSysProject>
<mesh>square_1x1_quad_1e3.vtu</mesh>
<geometry>square_1x1.gml</geometry>
<processes>
<process>
<name>hc</name>
<type>ComponentTransport</type>
<integration_order>2</integration_order>
<process_variables>
<concentration>Si</concentration>
<pressure>pressure</pressure>
</process_variables>
<specific_body_force>0 0</specific_body_force>
<secondary_variables>
<secondary_variable internal_name="darcy_velocity" output_name="darcy_velocity"/>
</secondary_variables>
</process>
</processes>
<media>
<medium id="0">
<phases>
<phase>
<type>AqueousLiquid</type>
<components>
<component>
<name>Si</name>
<properties>
<property>
<name>pore_diffusion</name>
<type>Constant</type>
<value>1e-5</value>
</property>
<property>
<name>retardation_factor</name>
<type>Constant</type>
<value>1</value>
</property>
<property>
<name>decay_rate</name>
<type>Parameter</type>
<parameter_name>decay</parameter_name>
</property>
</properties>
</component>
</components>
<properties>
<property>
<name>density</name>
<type>Function</type>
<value>
<expression>1 + 0.026 * concentration + 5e-5 * (phase_pressure - 0.5)</expression>
</value>
<dvalue>
<variable_name>concentration</variable_name>
<expression>0.026</expression>
</dvalue>
<dvalue>
<variable_name>phase_pressure</variable_name>
<expression>5e-5</expression>
</dvalue>
<!-- Keep for testing of the Function type property resembling the Linear property
<type>Linear</type>
<reference_value>1</reference_value>
<independent_variable>
<variable_name>concentration</variable_name>
<reference_condition>0</reference_condition>
<slope>0.026</slope>
</independent_variable>
<independent_variable>
<variable_name>phase_pressure</variable_name>
<reference_condition>0.5</reference_condition>
<slope>5e-5</slope>
</independent_variable>
-->
</property>
<property>
<name>viscosity</name>
<type>Constant</type>
<value>1e-3</value>
</property>
</properties>
</phase>
</phases>
<properties>
<property>
<name>permeability</name>
<type>Parameter</type>
<parameter_name>kappa1</parameter_name>
</property>
<property>
<name>porosity</name>
<type>Parameter</type>
<parameter_name>constant_porosity_parameter</parameter_name>
</property>
<property>
<name>longitudinal_dispersivity</name>
<type>Constant</type>
<value>0</value>
</property>
<property>
<name>transversal_dispersivity</name>
<type>Constant</type>
<value>0</value>
</property>
</properties>
</medium>
</media>
<time_loop>
<processes>
<process ref="hc">
<nonlinear_solver>basic_picard</nonlinear_solver>
<convergence_criterion>
<type>PerComponentDeltaX</type>
<norm_type>NORM2</norm_type>
<reltols>5e-3 5e-3</reltols>
</convergence_criterion>
<time_discretization>
<type>BackwardEuler</type>
</time_discretization>
<time_stepping>
<type>FixedTimeStepping</type>
<t_initial> 0.0 </t_initial>
<t_end> 9e2 </t_end>
<timesteps>
<pair>
<repeat>10</repeat>
<delta_t>1e-2</delta_t>
</pair>
<pair>
<repeat>40</repeat>
<delta_t>4e-2</delta_t>
</pair>
<pair>
<repeat>50</repeat>
<delta_t>8e-2</delta_t>
</pair>
<pair>
<repeat>50</repeat>
<delta_t>2e-1</delta_t>
</pair>
<pair>
<repeat>50</repeat>
<delta_t>4e-1</delta_t>
</pair>
<pair>
<repeat>50</repeat>
<delta_t>8e-1</delta_t>
</pair>
<pair>
<repeat>200</repeat>
<delta_t>16e-1</delta_t>
</pair>
<pair>
<repeat>100</repeat>
<delta_t>20e-1</delta_t>
</pair>
<pair>
<repeat>500</repeat>
<delta_t>25e-1</delta_t>
</pair>
</timesteps>
</time_stepping>
</process>
</processes>
<output>
<type>VTK</type>
<prefix>DiffusionAndStorageAndAdvection</prefix>
<suffix>_ts_{:timestep}_t_{:time}</suffix>
<timesteps>
<pair>
<repeat>1</repeat>
<each_steps>100</each_steps>
</pair>
</timesteps>
<variables>
<variable>Si</variable>
<variable>pressure</variable>
<variable>darcy_velocity</variable>
</variables>
</output>
</time_loop>
<parameters>
<parameter>
<name>decay</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>c0</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>p0</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>p_Dirichlet_left</name>
<type>Constant</type>
<value>1</value>
</parameter>
<parameter>
<name>p_Dirichlet_right</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>c_Dirichlet_left</name>
<type>Constant</type>
<value>1</value>
</parameter>
<parameter>
<name>c_Dirichlet_right</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>constant_porosity_parameter</name>
<type>Constant</type>
<value>0.2</value>
</parameter>
<parameter>
<name>kappa1</name>
<type>Constant</type>
<values>1.239e-7 0 0 1.239e-7</values>
</parameter>
<parameter>
<name>kappa2</name>
<type>Constant</type>
<values>1e-3 0 0 1e-3</values>
</parameter>
</parameters>
<process_variables>
<process_variable>
<name>Si</name>
<components>1</components>
<order>1</order>
<initial_condition>c0</initial_condition>
<boundary_conditions>
<boundary_condition>
<geometrical_set>geometry</geometrical_set>
<geometry>left</geometry>
<type>Dirichlet</type>
<parameter>c_Dirichlet_left</parameter>
</boundary_condition>
<boundary_condition>
<geometrical_set>geometry</geometrical_set>
<geometry>right</geometry>
<type>Dirichlet</type>
<parameter>c_Dirichlet_right</parameter>
</boundary_condition>
</boundary_conditions>
</process_variable>
<process_variable>
<name>pressure</name>
<components>1</components>
<order>1</order>
<initial_condition>p0</initial_condition>
<boundary_conditions>
<boundary_condition>
<geometrical_set>geometry</geometrical_set>
<geometry>left</geometry>
<type>Dirichlet</type>
<parameter>p_Dirichlet_left</parameter>
</boundary_condition>
<boundary_condition>
<geometrical_set>geometry</geometrical_set>
<geometry>right</geometry>
<type>Dirichlet</type>
<parameter>p_Dirichlet_right</parameter>
</boundary_condition>
</boundary_conditions>
</process_variable>
</process_variables>
<nonlinear_solvers>
<nonlinear_solver>
<name>basic_picard</name>
<type>Picard</type>
<max_iter>10</max_iter>
<linear_solver>general_linear_solver</linear_solver>
</nonlinear_solver>
</nonlinear_solvers>
<linear_solvers>
<linear_solver>
<name>general_linear_solver</name>
<lis>-i bicgstab -p ilut -tol 1e-8 -maxiter 20000</lis>
<eigen>
<solver_type>BiCGSTAB</solver_type>
<precon_type>ILUT</precon_type>
<max_iteration_step>20000</max_iteration_step>
<error_tolerance>1e-8</error_tolerance>
</eigen>
<petsc>
<prefix>hc</prefix>
<parameters>-hc_ksp_type bcgs -hc_pc_type bjacobi -hc_ksp_rtol 1e-8 -hc_ksp_max_it 20000</parameters>
</petsc>
</linear_solver>
</linear_solvers>
</OpenGeoSysProject>
......@@ -65,6 +65,47 @@ test_that("read_in works for class objects with ellipsis", {
properties[[1]]$
independent_variable[[2]][["variable_name"]],
"phase_pressure")
prj_path <- (system.file("extdata/benchmarks/SimpleSynthetics",
"DiffusionAndStorageAndAdvection.prj",
package = "r2ogs6"))
ogs6_obj <- OGS6$new(sim_name = "sim",
sim_path = "sim_path")
read_in(ogs6_obj,
prj_path,
"/OpenGeoSysProject/media/medium")
expect_equal(ogs6_obj$
media[[1]]$
phases[[1]]$
properties[[1]]$
dvalue[[1]][["variable_name"]],
"concentration")
expect_equal(ogs6_obj$
media[[1]]$
phases[[1]]$
properties[[1]]$
dvalue[[1]][["expression"]],
0.026)
expect_equal(ogs6_obj$
media[[1]]$
phases[[1]]$
properties[[1]]$
dvalue[[2]][["variable_name"]],
"phase_pressure")
expect_equal(ogs6_obj$
media[[1]]$
phases[[1]]$
properties[[1]]$
dvalue[[2]][["expression"]],
5e-5)
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment