Newer
Older
#===== r2ogs6_medium =====
#'@description tag: medium, a specific medium with optional id corresponding
#' to the MaterialIDs
Ruben Heinrich
committed
#'@param phases list, r2ogs6_phase: Optional: Medium phases
#'@param properties list, r2ogs6_pr_property: Optional: Medium properties
#'@param id string | double: Optional: ID corresponding to the MaterialIDs
Ruben Heinrich
committed
r2ogs6_medium <- function(phases = NULL,
if(is.character(phases)){
phases <- NULL
}
new_r2ogs6_medium(phases,
properties,
id)
Ruben Heinrich
committed
new_r2ogs6_medium <- function(phases = NULL,
properties = NULL,
id = NULL) {
Ruben Heinrich
committed
if(length(phases) != 0){
is_wrapper_list(phases, "r2ogs6_phase")
Ruben Heinrich
committed
}
is_wrapper_list(properties, "r2ogs6_pr_property")
structure(
list(
phases = phases,
properties = properties,
id = id,
attr_names = c("id"),
flatten_on_exp = character()
),
class = "r2ogs6_medium"
)
}
#'@description tag: property
#'@param name string:
#'@param type string:
#'@param value Optional:
#'@param parameter_name Optional:
#'@param exponent Optional:
#'@param residual_liquid_saturation Optional:
#'@param residual_gas_saturation Optional:
#'@param p_b Optional:
#'@param independent_variable Optional:
#'@param curve Optional:
#'@param minimum_relative_permeability_liquid Optional:
#'@param initial_permeability Optional:
#'@param maximum_permeability Optional:
#'@param lambda Optional:
#'@param cutoff_value Optional:
#'@param intrinsic_permeability Optional:
#'@param initial_aperture Optional:
#'@param mean_frac_distance Optional:
#'@param threshold_strain Optional:
#'@param fracture_normal Optional:
#'@param reference_permeability Optional:
#'@param fitting_factor Optional:
#'@param cohesion Optional:
#'@param friction_angle Optional:
#'@param tensile_strength_parameter Optional:
#'@param b1 Optional:
#'@param b2 Optional:
#'@param b3 Optional:
#'@param minimum_permeability Optional:
#'@param initial_porosity Optional:
#'@param entry_pressure Optional:
#'@param min_relative_permeability_liquid Optional:
#'@param min_relative_permeability_gas Optional:
r2ogs6_pr_property <- function(name,
type,
value = NULL,
parameter_name = NULL,
exponent = NULL,
residual_liquid_saturation = NULL,
residual_gas_saturation = NULL,
p_b = NULL,
independent_variable = NULL,
curve = NULL,
minimum_relative_permeability_liquid = NULL,
initial_permeability = NULL,
maximum_permeability = NULL,
lambda = NULL,
cutoff_value = NULL,
intrinsic_permeability = NULL,
initial_aperture = NULL,
mean_frac_distance = NULL,
threshold_strain = NULL,
fracture_normal = NULL,
reference_permeability = NULL,
fitting_factor = NULL,
cohesion = NULL,
friction_angle = NULL,
tensile_strength_parameter = NULL,
b1 = NULL,
b2 = NULL,
b3 = NULL,
minimum_permeability = NULL,
initial_porosity = NULL,
entry_pressure = NULL,
min_relative_permeability_liquid = NULL,
min_relative_permeability_gas = NULL) {
value <- coerce_string_to_numeric(value)
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
exponent <- coerce_string_to_numeric(exponent)
residual_liquid_saturation <-
coerce_string_to_numeric(residual_liquid_saturation)
residual_gas_saturation <- coerce_string_to_numeric(residual_gas_saturation)
p_b <- coerce_string_to_numeric(p_b)
minimum_relative_permeability_liquid <-
coerce_string_to_numeric(minimum_relative_permeability_liquid)
lambda <- coerce_string_to_numeric(lambda)
cutoff_value <- coerce_string_to_numeric(cutoff_value)
reference_permeability <- coerce_string_to_numeric(reference_permeability)
fitting_factor <- coerce_string_to_numeric(fitting_factor)
cohesion <- coerce_string_to_numeric(cohesion)
friction_angle <- coerce_string_to_numeric(friction_angle)
maximum_permeability <- coerce_string_to_numeric(maximum_permeability)
tensile_strength_parameter <-
coerce_string_to_numeric(tensile_strength_parameter)
entry_pressure <- coerce_string_to_numeric(entry_pressure)
min_relative_permeability_liquid <-
coerce_string_to_numeric(min_relative_permeability_liquid)
min_relative_permeability_gas <-
coerce_string_to_numeric(min_relative_permeability_gas)
new_r2ogs6_pr_property(
name,
type,
value,
parameter_name,
exponent,
residual_liquid_saturation,
residual_gas_saturation,
p_b,
independent_variable,
curve,
minimum_relative_permeability_liquid,
initial_permeability,
maximum_permeability,
intrinsic_permeability,
initial_aperture,
mean_frac_distance,
threshold_strain,
fracture_normal,
reference_permeability,
fitting_factor,
cohesion,
friction_angle,
tensile_strength_parameter,
b1,
b2,
b3,
minimum_permeability,
initial_porosity,
entry_pressure,
min_relative_permeability_liquid,
min_relative_permeability_gas
)
}
new_r2ogs6_pr_property <- function(name,
type,
value = NULL,
parameter_name = NULL,
exponent = NULL,
residual_liquid_saturation = NULL,
residual_gas_saturation = NULL,
p_b = NULL,
independent_variable = NULL,
curve = NULL,
minimum_relative_permeability_liquid = NULL,
initial_permeability = NULL,
maximum_permeability = NULL,
lambda = NULL,
cutoff_value = NULL,
intrinsic_permeability = NULL,
initial_aperture = NULL,
mean_frac_distance = NULL,
threshold_strain = NULL,
fracture_normal = NULL,
reference_permeability = NULL,
fitting_factor = NULL,
cohesion = NULL,
friction_angle = NULL,
tensile_strength_parameter = NULL,
b1 = NULL,
b2 = NULL,
b3 = NULL,
minimum_permeability = NULL,
initial_porosity = NULL,
entry_pressure = NULL,
min_relative_permeability_liquid = NULL,
min_relative_permeability_gas = NULL) {
Ruben Heinrich
committed
assertthat::assert_that(assertthat::is.string(name))
assertthat::assert_that(assertthat::is.string(type))
residual_liquid_saturation,
residual_gas_saturation,
p_b,
minimum_relative_permeability_liquid,
lambda,
cutoff_value,
reference_permeability,
fitting_factor,
cohesion,
friction_angle,
maximum_permeability,
tensile_strength_parameter,
entry_pressure,
min_relative_permeability_liquid,
min_relative_permeability_gas)
are_null_or_strings(parameter_name,
independent_variable,
curve,
initial_permeability)
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
structure(list(name = name,
type = type,
value = value,
parameter_name = parameter_name,
exponent = exponent,
residual_liquid_saturation = residual_liquid_saturation,
residual_gas_saturation = residual_gas_saturation,
p_b = p_b,
independent_variable = independent_variable,
curve = curve,
minimum_relative_permeability_liquid =
minimum_relative_permeability_liquid,
initial_permeability = initial_permeability,
maximum_permeability = maximum_permeability,
lambda = lambda,
cutoff_value = cutoff_value,
intrinsic_permeability = intrinsic_permeability,
initial_aperture = initial_aperture,
mean_frac_distance = mean_frac_distance,
threshold_strain = threshold_strain,
fracture_normal = fracture_normal,
reference_permeability = reference_permeability,
fitting_factor = fitting_factor,
cohesion = cohesion,
friction_angle = friction_angle,
tensile_strength_parameter = tensile_strength_parameter,
b1 = b1,
b2 = b2,
b3 = b3,
minimum_permeability = minimum_permeability,
initial_porosity = initial_porosity,
entry_pressure = entry_pressure,
min_relative_permeability_liquid = min_relative_permeability_liquid,
min_relative_permeability_gas = min_relative_permeability_gas,
xpath = "media/medium/properties/property",
attr_names = character(),
flatten_on_exp = character()
),
class = "r2ogs6_pr_property"
)
}
#'@description tag: phase, a coherent material with homogeneous properties
#'@param type string: Phase type
#' (get valid types with get_valid_phase_types())
#'@param properties list, r2ogs6_pr_property: Properties
#'@param components list, components
#'@export
#Make this more user friendly
#...
new_r2ogs6_phase(type,
properties,
components)
}
new_r2ogs6_phase <- function(type,
Ruben Heinrich
committed
assertthat::assert_that(assertthat::is.string(type))
assertthat::assert_that(type %in% get_valid_phase_types())
is_wrapper_list(properties, "r2ogs6_ph_property")
if(!is.null(components)){
is_wrapper_list(components, "r2ogs6_component")
structure(
list(
type = type,
properties = properties,
components = components,
xpath = "media/medium/phases/phase",
attr_names = character(),
flatten_on_exp = character()
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
class = "r2ogs6_phase"
)
}
get_valid_phase_types <- function(){
valid_phase_types <- c("Gas",
"Solid",
"AqueousLiquid",
"NonAqueousLiquid")
return(invisible(valid_phase_types))
}
#===== r2ogs6_ph_property =====
#'r2ogs6_ph_property
#'@description tag: property
#'@param name string: Property name
#'@param type string: Property type
#'@param value Optional: string | double: ...
#'@param reference_value Optional: string | double:
#'@param initial_porosity Optional: string:
#'@param minimal_porosity Optional: string | double:
#'@param maximal_porosity Optional: string | double:
#'@param parameter_name Optional: string:
#'@param exponents Optional: string | numeric:
#'@param offset Optional: string | double:
#'@param exponent Optional: list:
#'@param swelling_pressures Optional: string | numeric:
#'@param lower_saturation_limit Optional: string | double:
#'@param upper_saturation_limit Optional: string | double:
#'@param intrinsic_permeabilities Optional: string | numeric:
#'@param ... independent_variable
#'@export
r2ogs6_ph_property <- function(name,
type,
value = NULL,
reference_value = NULL,
initial_porosity = NULL,
minimal_porosity = NULL,
maximal_porosity = NULL,
parameter_name = NULL,
exponents = NULL,
offset = NULL,
exponent = NULL,
swelling_pressures = NULL,
lower_saturation_limit = NULL,
upper_saturation_limit = NULL,
intrinsic_permeabilities = NULL,
...) {
value <- coerce_string_to_numeric(value)
reference_value <- coerce_string_to_numeric(reference_value)
minimal_porosity <- coerce_string_to_numeric(minimal_porosity)
maximal_porosity <- coerce_string_to_numeric(maximal_porosity)
exponents <- coerce_string_to_numeric(exponents)
offset <- coerce_string_to_numeric(offset)
swelling_pressures <- coerce_string_to_numeric(swelling_pressures)
lower_saturation_limit <- coerce_string_to_numeric(lower_saturation_limit)
upper_saturation_limit <- coerce_string_to_numeric(upper_saturation_limit)
intrinsic_permeabilities <-
coerce_string_to_numeric(intrinsic_permeabilities)
ellipsis_list <- list(...)
independent_variable <-
ellipsis_list[names(ellipsis_list) == "independent_variable"]
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
new_r2ogs6_ph_property(
name,
type,
value,
reference_value,
independent_variable,
initial_porosity,
minimal_porosity,
maximal_porosity,
parameter_name,
exponents,
offset,
exponent,
swelling_pressures,
lower_saturation_limit,
upper_saturation_limit,
intrinsic_permeabilities
)
}
new_r2ogs6_ph_property <- function(name,
type,
value = NULL,
reference_value = NULL,
independent_variable = NULL,
initial_porosity = NULL,
minimal_porosity = NULL,
maximal_porosity = NULL,
parameter_name = NULL,
exponents = NULL,
offset = NULL,
exponent = NULL,
swelling_pressures = NULL,
lower_saturation_limit = NULL,
upper_saturation_limit = NULL,
intrinsic_permeabilities = NULL) {
assertthat::assert_that(assertthat::is.string(name))
assertthat::assert_that(assertthat::is.string(type))
are_null_or_numbers(reference_value,
minimal_porosity,
maximal_porosity,
offset,
lower_saturation_limit,
upper_saturation_limit)
swelling_pressures,
intrinsic_permeabilities)
are_null_or_strings(initial_porosity,
parameter_name)
if (!is.null(independent_variable)) {
for(i in seq_len(length(independent_variable))){
independent_variable[[i]] <-
coerce_names(independent_variable[[i]],
c("variable_name",
"reference_condition",
"slope"))
}
}
if (!is.null(exponent)) {
exponent <- coerce_names(exponent,
c("variable_name",
"reference_condition",
"factor"))
}
structure(
list(
name = name,
type = type,
value = value,
reference_value = reference_value,
independent_variable = independent_variable,
initial_porosity = initial_porosity,
minimal_porosity = minimal_porosity,
maximal_porosity = maximal_porosity,
parameter_name = parameter_name,
exponents = exponents,
offset = offset,
exponent = exponent,
swelling_pressures = swelling_pressures,
lower_saturation_limit = lower_saturation_limit,
upper_saturation_limit = upper_saturation_limit,
intrinsic_permeabilities = intrinsic_permeabilities,
xpath = "media/medium/phases/phase/properties/property",
attr_names = character(),
flatten_on_exp = c("exponents",
"swelling_pressures",
"intrinsic_permeabilities"),
unwrap_on_exp = c("independent_variable")
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
),
class = "r2ogs6_ph_property"
)
}
#===== r2ogs6_component =====
#'r2ogs6_component
#'@description tag: component
#'@param name string:
#'@param properties list, r2ogs6_com_property:
#'@export
r2ogs6_component <- function(name,
properties){
#Make this more user friendly
#...
new_r2ogs6_component(name,
properties)
}
new_r2ogs6_component <- function(name,
properties) {
assertthat::assert_that(assertthat::is.string(name))
is_wrapper_list(properties, "r2ogs6_com_property")
structure(
list(
name = name,
properties = properties,
xpath = "media/medium/phases/phase/components/component",
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
attr_names = character(),
flatten_on_exp = character()
),
class = "r2ogs6_component"
)
}
#===== r2ogs6_com_property =====
#'r2ogs6_com_property
#'@description tag: property
#'@param name string: Property name
#'@param type string: Property type
#'@param value Optional: string | double: ...
#'@param parameter_name Optional:
#'@export
r2ogs6_com_property <- function(name,
type,
value = NULL,
parameter_name = NULL) {
#Coerce input
value <- coerce_string_to_numeric(value)
Ruben Heinrich
committed
new_r2ogs6_com_property(name,
type,
value,
parameter_name)
}
new_r2ogs6_com_property <- function(name,
type,
value = NULL,
parameter_name = NULL) {
assertthat::assert_that(assertthat::is.string(name))
assertthat::assert_that(assertthat::is.string(type))
are_null_or_numbers(value)
are_null_or_strings(parameter_name)
structure(
list(
name = name,
type = type,
value = value,
parameter_name = parameter_name,
xpath = paste0("media/medium/phases/phase/components/component",
"properties/property"),
attr_names = character(),
flatten_on_exp = character()
),
class = "r2ogs6_com_property"