fix: Correct boolean conversion in DHT hook call

This commit is contained in:
Max Lübke 2025-03-12 10:07:17 +01:00
parent 5a7779e8de
commit 66d908b548
3 changed files with 26 additions and 26 deletions

View File

@ -41,36 +41,36 @@ diffusion_setup <- list(
) )
check_sign_cal_dol_dht <- function(old, new) { check_sign_cal_dol_dht <- function(old, new) {
if ((old["Calcite"] == 0) != (new["Calcite"] == 0)) { # if ((old["Calcite"] == 0) != (new["Calcite"] == 0)) {
return(TRUE) # return(TRUE)
} # }
if ((old["Dolomite"] == 0) != (new["Dolomite"] == 0)) { # if ((old["Dolomite"] == 0) != (new["Dolomite"] == 0)) {
return(TRUE) # return(TRUE)
} # }
return(FALSE) return(FALSE)
} }
fuzz_input_dht_keys <- function(input) { # fuzz_input_dht_keys <- function(input) {
dht_species <- c( # dht_species <- c(
"H" = 3, # "H" = 3,
"O" = 3, # "O" = 3,
"Charge" = 3, # "Charge" = 3,
"C(4)" = 6, # "C" = 6,
"Ca" = 6, # "Ca" = 6,
"Cl" = 3, # "Cl" = 3,
"Mg" = 5, # "Mg" = 5,
"Calcite" = 4, # "Calcite" = 4,
"Dolomite" = 4 # "Dolomite" = 4
) # )
return(input[names(dht_species)]) # return(input[names(dht_species)])
} # }
check_sign_cal_dol_interp <- function(to_interp, data_set) { check_sign_cal_dol_interp <- function(to_interp, data_set) {
dht_species <- c( dht_species <- c(
"H" = 3, "H" = 3,
"O" = 3, "O" = 3,
"Charge" = 3, "Charge" = 3,
"C(4)" = 6, "C" = 6,
"Ca" = 6, "Ca" = 6,
"Cl" = 3, "Cl" = 3,
"Mg" = 5, "Mg" = 5,
@ -95,7 +95,7 @@ check_neg_cal_dol <- function(result) {
# significant digits) # significant digits)
pht_species <- c( pht_species <- c(
"C(4)" = 3, "C" = 3,
"Ca" = 3, "Ca" = 3,
"Mg" = 2, "Mg" = 2,
"Calcite" = 2, "Calcite" = 2,
@ -107,7 +107,7 @@ chemistry_setup <- list(
"H" = 3, "H" = 3,
"O" = 3, "O" = 3,
"Charge" = 3, "Charge" = 3,
"C(4)" = 6, "C" = 6,
"Ca" = 6, "Ca" = 6,
"Cl" = 3, "Cl" = 3,
"Mg" = 5, "Mg" = 5,
@ -117,7 +117,7 @@ chemistry_setup <- list(
pht_species = pht_species, pht_species = pht_species,
hooks = list( hooks = list(
dht_fill = check_sign_cal_dol_dht, dht_fill = check_sign_cal_dol_dht,
dht_fuzz = fuzz_input_dht_keys, # dht_fuzz = fuzz_input_dht_keys,
interp_pre = check_sign_cal_dol_interp, interp_pre = check_sign_cal_dol_interp,
interp_post = check_neg_cal_dol interp_post = check_neg_cal_dol
) )

View File

@ -144,7 +144,7 @@ void DHT_Wrapper::fillDHT(const WorkPackage &work_package) {
NamedVector<double> old_values(output_names, work_package.input[i]); NamedVector<double> old_values(output_names, work_package.input[i]);
NamedVector<double> new_values(output_names, work_package.output[i]); NamedVector<double> new_values(output_names, work_package.output[i]);
if (hooks.dht_fill(old_values, new_values)) { if (Rcpp::as<bool>(hooks.dht_fill(old_values, new_values))) {
continue; continue;
} }
} }

View File

@ -145,7 +145,7 @@ void InterpolationModule::tryInterpolation(WorkPackage &work_package) {
if (hooks.interp_post.isValid()) { if (hooks.interp_post.isValid()) {
NamedVector<double> nv_result(this->out_names, work_package.output[wp_i]); NamedVector<double> nv_result(this->out_names, work_package.output[wp_i]);
if (hooks.interp_post(nv_result)) { if (Rcpp::as<bool>(hooks.interp_post(nv_result))) {
interp_result.status[wp_i] = INSUFFICIENT_DATA; interp_result.status[wp_i] = INSUFFICIENT_DATA;
continue; continue;
} }