content
stringlengths
0
14.9M
filename
stringlengths
44
136
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 0.4kV Board #' @description This function calculates the current #' annual probability of failure for 0.4kV Board #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' A sting that refers to the specific asset category. #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. #' A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' @inheritParams current_health #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for 0.4kV board #' pof_board_04kv( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "compound_leaks" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_cond" = list("Condition Criteria: Observed Condition" = "Default"), #' "insulation" = list("Condition Criteria: Observed Condition" = "Default"), #' "signs_heating" = list("Condition Criteria: Observed Condition" = "Default"), #' "phase_barriers" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("opsal_adequacy" = #' list("Condition Criteria: Operational Adequacy" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0069, #' c_value = 1.087, #' normal_expected_life = 60) pof_board_04kv <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0069, c_value = 1.087, normal_expected_life = 60) { lv_asset_category <- "LV Board (WM)" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = lv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) asset_category_mmi <- get_mmi_lv_switchgear_asset_category(lv_asset_category) # Measured conditions mci_table_names <- list("opsal_adequacy" = "mci_lv_board_wm_opsal_adequacy") measured_condition_modifier <- get_measured_conditions_modifier_lv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list( "external_cond" = "oci_lv_board_swg_ext_cond", "compound_leaks" = "oci_lv_board_wm_compound_leak", "internal_cond" = "oci_lv_board_wm_swg_int_cond", "insulation" = "oci_lv_board_wm_insulation_cond", "signs_heating" = "oci_lv_board_wm_signs_heating", "phase_barriers" = "oci_lv_board_wm_phase_barriers" ) observed_condition_modifier <- get_observed_conditions_modifier_lv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_board_04kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for Primary Substation Building #' and Secondary Substation Building. #' @description This function calculates the current #' annual probability of failure for primary substation building #' and secondary substation building. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param substation_type String. A sting that refers to the specific #' substation type. #' Options: #' \code{substation_type = c("Primary", "Secondary")}. #' The default setting is #' \code{substation_type = "Secondary"} #' @param material_type String. A sting that refers to the specific #' material_type. #' Options: #' \code{material_type = c("Brick", "Steel", "Wood")}. #' The default setting is #' \code{substation_type = "Wood"} #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @inheritParams duty_factor_transformer_33_66kv #' @inheritParams location_factor #' @inheritParams current_health #' @param age Numeric. The current age in years #' of the building. #' @param temperature_reading String. Indicating the criticality. #' Options: #' \code{temperature_reading = c("Normal", "Moderately High", #' "Very High", "Default")}. #' @param coolers_radiator String. Indicating the observed condition of the #' coolers/radiators. Options: #' \code{coolers_radiator = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param kiosk String. Indicating the observed condition of the #' kiosk. Options: #' \code{kiosk = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' @param cable_boxes String. Indicating the observed condition of the #' cable boxes. Options: #' \code{cable_boxes = c("No Deterioration","Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}.. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param k_value Numeric. \code{k_value = "Default"} by default. This number is #' given in a percentage. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life_building Numeric. #' \code{normal_expected_life_building = "Default"} by default. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' pof_building(substation_type = "Secondary", #' material_type = "Wood", #' placement = "Outdoor", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 43, #' temperature_reading = "Default", #' coolers_radiator = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' reliability_factor = "Default", #' k_value = "Default", #' c_value = 1.087, #' normal_expected_life_building = "Default") pof_building <- function(substation_type = "Secondary", material_type = "Wood", placement = "Outdoor", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, temperature_reading = "Default", coolers_radiator = "Default", kiosk = "Default", cable_boxes = "Default", reliability_factor = "Default", k_value = "Default", c_value = 1.087, normal_expected_life_building = "Default") { transformer_type <- "66kV Transformer (GM)" # This is done to use some of CNAIM's tables `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for Building ----------------------------- if (substation_type == "Primary") { primary_factor <- 1.2 } else { primary_factor <- 1 } if (normal_expected_life_building == "Default" && material_type == "Brick") { normal_expected_life <- 100/primary_factor } else if (normal_expected_life_building == "Default" && material_type == "Steel") { normal_expected_life <- 80/primary_factor } else if (normal_expected_life_building == "Default" && material_type == "Wood") { normal_expected_life <- 60/primary_factor } else { normal_expected_life <- normal_expected_life_building/primary_factor } # Constants C and K for PoF function -------------------------------------- if (k_value == "Default" && material_type == "Brick") { k <- (0.1/100)*primary_factor } else if (k_value == "Default" && material_type == "Steel") { k <- (0.2/100)*primary_factor } else if (k_value == "Default" && material_type == "Wood") { k <- (0.4/100)*primary_factor } else { k <- (k_value/100)*primary_factor } c <- c_value # Duty factor ------------------------------------------------------------- duty_factor <- duty_factor_transformer_33_66kv() duty_factor <- duty_factor$duty_factor[which(duty_factor$category == "transformer")] # Location factor ---------------------------------------------------- location_factor <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for building------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor, location_factor) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "EHV Transformer (GM)"), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) # Temperature readings ---------------------------------------------------- mci_temp_readings <- gb_ref$mci_ehv_tf_temp_readings ci_factor_temp_reading <- mci_temp_readings$`Condition Input Factor`[which( mci_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_temp_readings$`Condition Input Cap`[which( mci_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_temp_readings$`Condition Input Collar`[which( mci_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors <- ci_factor_temp_reading measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) # Measured condition cap -------------------------------------------------- measured_condition_cap <- ci_cap_temp_reading # Measured condition collar ----------------------------------------------- measured_condition_collar <- ci_collar_temp_reading # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "EHV Transformer (GM)") factor_divider_1_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) # Building ------------------------------------------------------------- # Coolers/Radiator condition oci_cooler_radiatr_cond <- gb_ref$oci_ehv_tf_cooler_radiatr_cond Oi_collar_coolers_radiator <- oci_cooler_radiatr_cond$`Condition Input Collar`[which( oci_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_cooler_radiatr_cond$`Condition Input Cap`[which( oci_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_cooler_radiatr_cond$`Condition Input Factor`[which( oci_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Kiosk oci_kiosk_cond <- gb_ref$oci_ehv_tf_kiosk_cond Oi_collar_kiosk <- oci_kiosk_cond$`Condition Input Collar`[which( oci_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_kiosk_cond$`Condition Input Cap`[which( oci_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_kiosk_cond$`Condition Input Factor`[which( oci_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_cable_boxes_cond <- gb_ref$oci_ehv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_cable_boxes_cond$`Condition Input Collar`[which( oci_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_cable_boxes_cond$`Condition Input Cap`[which( oci_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_cable_boxes_cond$`Condition Input Factor`[which( oci_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Observed condition factor -------------------------------------- factors_obs <- c(Oi_factor_coolers_radiator, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor <- mmi(factors_obs, factor_divider_1_obs, factor_divider_2_obs, max_no_combined_factors_obs) # Observed condition cap ----------------------------------------- caps_obs <- c(Oi_cap_coolers_radiator, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap <- min(caps_obs) # Observed condition collar --------------------------------------- collars_obs <- c(Oi_collar_coolers_radiator, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar <- max(collars_obs) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- gb_ref$health_score_factor_for_tf factor_divider_1_health <- health_score_factor$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_health <- health_score_factor$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_health <- health_score_factor$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- obs_factor <- observed_condition_modifier$observed_condition_factor mea_factor <- measured_condition_modifier$measured_condition_factor factors_health <- c(obs_factor, mea_factor) health_score_factor <- mmi(factors_health, factor_divider_1_health, factor_divider_2_health, max_no_combined_factors_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_building.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 0.4kV UG PEX Non Pressurised Cables #' @description This function calculates the current #' annual probability of failure per kilometer for a 0.4kV Pex non Pressurised cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams duty_factor_cables #' @param sheath_test String. Only applied for non pressurised cables. #' Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. #' @param partial_discharge String. Only applied for non pressurised cables. #' Indicating the level of partial discharge. Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. #' @param fault_hist Numeric. Only applied for non pressurised cables. #' The calculated fault rate for the cable in the period per kilometer. #' A setting of \code{"No historic faults recorded"} #' indicates no fault. #' @inheritParams current_health #' @param age Numeric. The current age in years of the cable. #' @param k_value Numeric. \code{k_value = 0.0658} by default. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 80} by default. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for 0.4kV non pressurised pex cable, 50 years old #' pof_cables_04kv_pex( #' utilisation_pct = 80, #' operating_voltage_pct = "Default", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.0658, #' c_value = 1.087, #' normal_expected_life = 80) pof_cables_04kv_pex <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.0658, c_value = 1.087, normal_expected_life = 80) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL cable_type <- "33kV UG Cable (Non Pressurised)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_cables_04kv_pex.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 10kV UG Oil Non Preesurised Cables (Armed Paper Lead) #' @description This function calculates the current #' annual probability of failure per kilometer for a Oil non Preesurised cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams duty_factor_cables #' @param sheath_test String. Only applied for non pressurised cables. #' Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. #' @param partial_discharge String. Only applied for non pressurised cables. #' Indicating the level of partial discharge. Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. #' @param fault_hist Numeric. Only applied for non pressurised cables. #' The calculated fault rate for the cable in the period per kilometer. #' A setting of \code{"No historic faults recorded"} #' indicates no fault. #' @inheritParams current_health #' @param age Numeric. The current age in years of the cable. #' @param k_value Numeric. \code{k_value = 0.24} by default. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 80} by default. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for 10kV oil cable, 50 years old #' pof_cables_10kv_oil( #' utilisation_pct = 80, #' operating_voltage_pct = "Default", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.24, #' c_value = 1.087, #' normal_expected_life = 80) pof_cables_10kv_oil <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.24, c_value = 1.087, normal_expected_life = 80) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL cable_type <- "33kV UG Cable (Oil)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_cables_10kv_oil.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 10kV UG PEX Non Pressurised Cables #' @description This function calculates the current #' annual probability of failure per kilometer for a 10kV PEX non Pressurised cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams duty_factor_cables #' @param sheath_test String. Only applied for non pressurised cables. #' Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. #' @param partial_discharge String. Only applied for non pressurised cables. #' Indicating the level of partial discharge. Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. #' @param fault_hist Numeric. Only applied for non pressurised cables. #' The calculated fault rate for the cable in the period per kilometer. #' A setting of \code{"No historic faults recorded"} #' indicates no fault. #' @inheritParams current_health #' @param age Numeric. The current age in years of the cable. #' @param k_value Numeric. \code{k_value = 0.0658} by default. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 80} by default. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for 10kV pex cable, 50 years old #' pof_cables_10kv_pex( #' utilisation_pct = 80, #' operating_voltage_pct = "Default", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.0658, #' c_value = 1.087, #' normal_expected_life = 80) pof_cables_10kv_pex <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.0658, c_value = 1.087, normal_expected_life = 80) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL cable_type <- "33kV UG Cable (Non Pressurised)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_cables_10kv_pex.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 132kV cables #' @description This function calculates the current #' annual probability of failure per kilometer for a 132kV cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param cable_type String. #' A sting that refers to the specific asset category. #' See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{cable_type = c("132kV UG Cable (Gas)", "132kV UG Cable (Gas)", #' "132kV UG Cable (Non Pressurised)") #'}. The default setting is #' \code{cable_type = "132kV UG Cable (Gas)"}. #' @param sub_division String. Refers to material the sheath and conductor is #' made of. Options: #' \code{sub_division = c("Aluminium sheath - Aluminium conductor", #' "Aluminium sheath - Copper conductor", #' "Lead sheath - Aluminium conductor", "Lead sheath - Copper conductor") #'} #' @inheritParams duty_factor_cables #' @param sheath_test String. Only applied for non pressurised cables. #' Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. See page 157, table 184 in CNAIM (2021). #' @param partial_discharge String. Only applied for non pressurised cables. #' Indicating the level of partial discharge. Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. See page 157, table 185 in CNAIM (2021). #' @param fault_hist Numeric. Only applied for non pressurised cables. #' The calculated fault rate for the cable in the period per kilometer. #' A setting of \code{"No historic faults recorded"} #' indicates no fault. See page 157, table 186 in CNAIM (2021). #' @param leakage String. Only applied for oil and gas pressurised cables. #' Options: #' \code{leakage = c("No (or very low) historic leakage recorded", #' "Low/ moderate", "High", "Very High", "Default")}. #' See page 158, table 187 (oil) and 188 (gas) in CNAIM (2021). #' @inheritParams current_health #' @param age Numeric. The current age in years of the cable. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for #' # "132kV UG Cable (Non Pressurised)", 50 years old #'pof_cables_132kV_non <- #'pof_cables_132kv(cable_type = "132kV UG Cable (Non Pressurised)", #'sub_division = "Lead sheath - Copper conductor", #'utilisation_pct = 80, #'operating_voltage_pct = 60, #'sheath_test = "Default", #'partial_discharge = "Default", #'fault_hist = "Default", #'leakage = "Default", #'reliability_factor = "Default", #'age = 50) * 100 #' #'paste0(sprintf("Probability of failure %.4f", pof_cables_132kV_non), #'" percent per annum") pof_cables_132kv <- function(cable_type = "132kV UG Cable (Gas)", sub_division = "Aluminium sheath - Aluminium conductor", utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", leakage = "Default", reliability_factor = "Default", age) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Condition Criteria: Leakage Rate` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == cable_type & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- if (asset_category == "132kV UG Cable (Non Pressurised)") { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl("Non Pressurised", gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } else { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl(asset_category, gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "EHV") # EHV and 132kv have identical duty factors # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- asset_category_mmi <- gsub(pattern = "UG", "", asset_category) asset_category_mmi <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", asset_category_mmi, perl=TRUE) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- if (asset_category == "132kV UG Cable (Non Pressurised)") { mci_132kv_cbl_non_pr_shth_test <- gb_ref$mci_132kv_cbl_non_pr_shth_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_132kv_cbl_non_pr_shth_test$`Condition Input Factor` ci_cap_sheath <- mci_132kv_cbl_non_pr_shth_test$`Condition Input Cap` ci_collar_sheath <- mci_132kv_cbl_non_pr_shth_test$`Condition Input Collar` mci_132kv_cbl_non_pr_prtl_disc <- gb_ref$mci_132kv_cbl_non_pr_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) # Partial discharge------------------------------------------------------- ci_factor_partial <- mci_132kv_cbl_non_pr_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_132kv_cbl_non_pr_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_132kv_cbl_non_pr_prtl_disc$`Condition Input Collar` mci_132kv_cbl_non_pr_flt_hist <- gb_ref$mci_132kv_cbl_non_pr_flt_hist # Fault ------------------------------------------------------- for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_132kv_cbl_non_pr_flt_hist$Upper == fault_hist) ci_factor_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_132kv_cbl_non_pr_flt_hist$Lower[n]) & fault_hist < as.numeric(mci_132kv_cbl_non_pr_flt_hist$Upper[n])) { ci_factor_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) } else if (asset_category == "132kV UG Cable (Oil)") { mci_132kv_cable_oil_leakage <- gb_ref$mci_132kv_cable_oil_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_oil <- mci_132kv_cable_oil_leakage$`Condition Input Factor` ci_cap_leakage_oil <- mci_132kv_cable_oil_leakage$`Condition Input Cap` ci_collar_leakage_oil <- mci_132kv_cable_oil_leakage$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_oil measured_condition_cap <- ci_cap_leakage_oil measured_condition_collar <- ci_collar_leakage_oil } else if (asset_category == "132kV UG Cable (Gas)") { mci_132kv_cbl_gas <- gb_ref$mci_132kv_cable_gas_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_gas <- mci_132kv_cbl_gas$`Condition Input Factor` ci_cap_leakage_gas <- mci_132kv_cbl_gas$`Condition Input Cap` ci_collar_leakage_gas <- mci_132kv_cbl_gas$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_gas measured_condition_cap <- ci_cap_leakage_gas measured_condition_collar <- ci_collar_leakage_gas } # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_cables_132kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 30-60kV cables #' @description This function calculates the current #' annual probability of failure per kilometer for a 30-60kV cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param cable_type String. #' A sting that refers to the specific asset category. #' See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{cable_type = c("30kV UG Cable (Gas)", "60kV UG Cable (Gas)", #' "30kV UG Cable (Non Pressurised)", "60kV UG Cable (Non Pressurised)", #' "30kV UG Cable (Oil)", "60kV UG Cable (Oil)") #'}. The default setting is #' \code{cable_type = "60kV UG Cable (Gas)"}. #' @param sub_division String. Refers to material the sheath and conductor is #' made of. Options: #' \code{sub_division = c("Aluminium sheath - Aluminium conductor", #' "Aluminium sheath - Copper conductor", #' "Lead sheath - Aluminium conductor", "Lead sheath - Copper conductor") #'} #' @inheritParams duty_factor_cables #' @param sheath_test String. Only applied for non pressurised cables. #' Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. See page 153, table 168 in CNAIM (2021). #' @param partial_discharge String. Only applied for non pressurised cables. #' Indicating the level of partial discharge. Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. See page 153, table 169 in CNAIM (2021). #' @param fault_hist Numeric. Only applied for non pressurised cables. #' The calculated fault rate for the cable in the period per kilometer. #' A setting of \code{"No historic faults recorded"} #' indicates no fault. See page 153, table 170 in CNAIM (2021). #' @param leakage String. Only applied for oil and gas pressurised cables. #' Options: #' \code{leakage = c("No (or very low) historic leakage recorded", #' "Low/ moderate", "High", "Very High", "Default")}. #' See page 157, table 182 (oil) and 183 (gas) in CNAIM (2021). #' @inheritParams current_health #' @param age Numeric. The current age in years of the cable. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for #' # "60kV UG Cable (Non Pressurised)", 50 years old #'pof_cables_60_30kv(cable_type = "66kV UG Cable (Non Pressurised)", #'sub_division = "Lead sheath - Copper conductor", #'utilisation_pct = 80, #'operating_voltage_pct = 60, #'sheath_test = "Default", #'partial_discharge = "Default", #'fault_hist = "Default", #'leakage = "Default", #'reliability_factor = "Default", #'age = 50) pof_cables_60_30kv <- function(cable_type = "60kV UG Cable (Gas)", sub_division = "Aluminium sheath - Aluminium conductor", utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", leakage = "Default", reliability_factor = "Default", age) { if (cable_type == "30kV UG Cable (Non Pressurised)" ) { cable_type <- "33kV UG Cable (Non Pressurised)" } else if ( cable_type == "30kV UG Cable (Oil)") { cable_type <- "33kV UG Cable (Oil)" } else if ( cable_type == "30kV UG Cable (Gas)") { cable_type <- "33kV UG Cable (Gas)" } else if ( cable_type == "60kV UG Cable (Non Pressurised)") { cable_type <- "66kV UG Cable (Non Pressurised)" } else if ( cable_type == "60kV UG Cable (Oil)") { cable_type <- "66kV UG Cable (Oil)" } else { cable_type <- "66kV UG Cable (Gas)" } `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Condition Criteria: Leakage Rate` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == cable_type & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl("Non Pressurised", gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } else { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl(asset_category, gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "EHV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- asset_category_mmi <- gsub(pattern = "UG", "", asset_category) asset_category_mmi <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", asset_category_mmi, perl=TRUE) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) # Partial discharge------------------------------------------------------- ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist # Fault ------------------------------------------------------- for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) } else if (asset_category == "EHV UG Cable (Oil)") { mci_ehv_cable_oil_leakage <- gb_ref$mci_ehv_cable_oil_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Factor` ci_cap_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Cap` ci_collar_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_oil measured_condition_cap <- ci_cap_leakage_oil measured_condition_collar <- ci_collar_leakage_oil } else if (asset_category == "EHV UG Cable (Gas)") { mci_ehv_cbl_gas <- gb_ref$mci_ehv_cable_gas_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Factor` ci_cap_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Cap` ci_collar_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_gas measured_condition_cap <- ci_cap_leakage_gas measured_condition_collar <- ci_collar_leakage_gas } # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_cables_60_30kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 33-66kV cables #' @description This function calculates the current #' annual probability of failure per kilometer for a 33-66kV cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param cable_type String. #' A sting that refers to the specific asset category. #' See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{cable_type = c("33kV UG Cable (Gas)", "66kV UG Cable (Gas)", #' "33kV UG Cable (Non Pressurised)", "66kV UG Cable (Non Pressurised)", #' "33kV UG Cable (Oil)", "66kV UG Cable (Oil)") #'}. The default setting is #' \code{cable_type = "66kV UG Cable (Gas)"}. #' @param sub_division String. Refers to material the sheath and conductor is #' made of. Options: #' \code{sub_division = c("Aluminium sheath - Aluminium conductor", #' "Aluminium sheath - Copper conductor", #' "Lead sheath - Aluminium conductor", "Lead sheath - Copper conductor") #'} #' @inheritParams duty_factor_cables #' @param sheath_test String. Only applied for non pressurised cables. #' Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. See page 153, table 168 in CNAIM (2021). #' @param partial_discharge String. Only applied for non pressurised cables. #' Indicating the level of partial discharge. Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. See page 153, table 169 in CNAIM (2021). #' @param fault_hist Numeric. Only applied for non pressurised cables. #' The calculated fault rate for the cable in the period per kilometer. #' A setting of \code{"No historic faults recorded"} #' indicates no fault. See page 153, table 170 in CNAIM (2021). #' @param leakage String. Only applied for oil and gas pressurised cables. #' Options: #' \code{leakage = c("No (or very low) historic leakage recorded", #' "Low/ moderate", "High", "Very High", "Default")}. #' See page 157, table 182 (oil) and 183 (gas) in CNAIM (2021). #' @inheritParams current_health #' @param age Numeric. The current age in years of the cable. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for #' # "66kV UG Cable (Non Pressurised)", 50 years old #' pof_cables_66_33kv(cable_type = "66kV UG Cable (Non Pressurised)", #' sub_division = "Lead sheath - Copper conductor", #' utilisation_pct = 80, #' operating_voltage_pct = 60, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' leakage = "Default", #' reliability_factor = "Default", #' age = 50) pof_cables_66_33kv <- function(cable_type = "66kV UG Cable (Gas)", sub_division = "Aluminium sheath - Aluminium conductor", utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", leakage = "Default", reliability_factor = "Default", age) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Condition Criteria: Leakage Rate` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == cable_type & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl("Non Pressurised", gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } else { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl(asset_category, gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "EHV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- asset_category_mmi <- gsub(pattern = "UG", "", asset_category) asset_category_mmi <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", asset_category_mmi, perl=TRUE) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) # Partial discharge------------------------------------------------------- ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist # Fault ------------------------------------------------------- for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) } else if (asset_category == "EHV UG Cable (Oil)") { mci_ehv_cable_oil_leakage <- gb_ref$mci_ehv_cable_oil_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Factor` ci_cap_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Cap` ci_collar_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_oil measured_condition_cap <- ci_cap_leakage_oil measured_condition_collar <- ci_collar_leakage_oil } else if (asset_category == "EHV UG Cable (Gas)") { mci_ehv_cbl_gas <- gb_ref$mci_ehv_cable_gas_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Factor` ci_cap_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Cap` ci_collar_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_gas measured_condition_cap <- ci_cap_leakage_gas measured_condition_collar <- ci_collar_leakage_gas } # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_cables_66_33kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for EHV/132kV Fittings #' @description This function calculates the current #' annual probability of failure per kilometer EHV Fittings #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param ehv_asset_category String The type of EHV asset category #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for EHV Swicthgear #' pof_ehv_fittings( #' ehv_asset_category = "33kV Fittings", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("insulator_elec_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "insulator_mech_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "conductor_fitting_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "tower_fitting_cond" = #' list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("thermal_imaging" = #' list("Condition Criteria: Thermal Imaging Result" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Result" = "Default")), #' reliability_factor = "Default") pof_ehv_fittings <- function(ehv_asset_category = "33kV Fittings", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ehv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == ehv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. pof_asset_category <- "Fittings" k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ehv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("thermal_imaging" = "mci_ehv_fittings_thrml_imaging", "ductor_test" = "mci_ehv_fittings_ductor_test") asset_category_mmi <- "EHV Fittings" if(ehv_asset_category == "132kV Fittings"){ asset_category_mmi <- "132kV Fittings" } measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("insulator_elec_cond" = "oci_ehv_fitg_insltr_elect_cond", "insulator_mech_cond" = "oci_ehv_fitg_insltr_mech_cond", "conductor_fitting_cond" = "oci_ehv_cond_fitting_cond", "tower_fitting_cond" = "oci_ehv_twr_fitting_cond") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_ehv_fittings.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for EHV Switchgear #' @description This function calculates the current #' annual probability of failure per kilometer EHV Switchgear #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param ehv_asset_category String The type of EHV asset category #' @param number_of_operations The number of operations for duty factor #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for EHV Swicthgear #' pof_ehv_switchgear( #' ehv_asset_category = "33kV RMU", #' number_of_operations = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default"), #' "support_structure" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default"), #' "ir_test" = list("Condition Criteria: IR Test Results" = "Default" )), #' reliability_factor = "Default") pof_ehv_switchgear <- function(ehv_asset_category = "33kV RMU", placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ehv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == ehv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. pof_asset_category <- get_pof_ehv_asset_category(ehv_asset_category) k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- get_duty_factor_hv_switchgear_primary(number_of_operations) # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ehv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_ehv_swg_partial_discharge", "ductor_test" = "mci_ehv_swg_ductor_test", "oil_test" = "mci_ehv_swg_oil_tests_gas_test", "temp_reading" = "mci_ehv_swg_temp_readings", "trip_test" = "mci_ehv_swg_trip_test", "ir_test"= "mci_ehv_swg_ir_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_ehv_swg_swg_ext_cond", "oil_gas" = "oci_ehv_swg_oil_leak_gas_pr", "thermo_assment" = "oci_ehv_swg_thermo_assessment", "internal_condition" = "oci_ehv_swg_swg_int_cond_ops", "indoor_env" = "oci_ehv_swg_indoor_environ", "support_structure" = "oci_ehv_swg_support_structure") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) } get_pof_ehv_asset_category <- function(ehv_asset_category){ if(grepl("66", ehv_asset_category, fixed = T)){ return("EHV Switchgear (GM) (66kV assets only)") } return("EHV Switchgear (GM) (33kV & 22kV assets only)") }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_ehv_switchgear.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 0.4kV Board #' @description This function calculates the future #' annual probability of failure per kilometer 0.4kV board. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_board_04kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 0.4kV board #' pof_future_board_04kv( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "compound_leaks" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_cond" = list("Condition Criteria: Observed Condition" = "Default"), #' "insulation" = list("Condition Criteria: Observed Condition" = "Default"), #' "signs_heating" = list("Condition Criteria: Observed Condition" = "Default"), #' "phase_barriers" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("opsal_adequacy" = #' list("Condition Criteria: Operational Adequacy" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0069, #' c_value = 1.087, #' normal_expected_life = 60, #' simulation_end_year = 100) pof_future_board_04kv <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0069, c_value = 1.087, normal_expected_life = 60, simulation_end_year = 100) { lv_asset_category <- "LV Board (WM)" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = lv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) asset_category_mmi <- get_mmi_lv_switchgear_asset_category(lv_asset_category) # Measured conditions mci_table_names <- list("opsal_adequacy" = "mci_lv_board_wm_opsal_adequacy") measured_condition_modifier <- get_measured_conditions_modifier_lv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list( "external_cond" = "oci_lv_board_swg_ext_cond", "compound_leaks" = "oci_lv_board_wm_compound_leak", "internal_cond" = "oci_lv_board_wm_swg_int_cond", "insulation" = "oci_lv_board_wm_insulation_cond", "signs_heating" = "oci_lv_board_wm_signs_heating", "phase_barriers" = "oci_lv_board_wm_phase_barriers" ) observed_condition_modifier <- get_observed_conditions_modifier_lv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_board_04kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Primary Substation Building #' and Secondary Substation Building. #' @description This function calculates the future #' annual probability of failure for primary substation building #' and secondary substation building. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_building #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future probability of failure for a Secondary substation Building #' pof_future_building(substation_type = "Secondary", #' material_type = "Wood", #' placement = "Outdoor", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 1, #' temperature_reading = "Default", #' coolers_radiator = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' reliability_factor = "Default", #' k_value = "Default", #' c_value = 1.087, #' normal_expected_life_building = "Default", #' simulation_end_year = 100) pof_future_building <- function(substation_type = "Secondary", material_type = "Wood", placement = "Outdoor", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, temperature_reading = "Default", coolers_radiator = "Default", kiosk = "Default", cable_boxes = "Default", reliability_factor = "Default", k_value = "Default", c_value = 1.087, normal_expected_life_building = "Default", simulation_end_year = 100) { transformer_type <- "66kV Transformer (GM)" # This is done to use some of CNAIM's tables `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for Building ----------------------------- if (substation_type == "Primary") { primary_factor <- 1.2 } else { primary_factor <- 1 } if (normal_expected_life_building == "Default" && material_type == "Brick") { normal_expected_life <- 100/primary_factor } else if (normal_expected_life_building == "Default" && material_type == "Steel") { normal_expected_life <- 80/primary_factor } else if (normal_expected_life_building == "Default" && material_type == "Wood") { normal_expected_life <- 60/primary_factor } else { normal_expected_life <- normal_expected_life_building/primary_factor } # Constants C and K for PoF function -------------------------------------- if (k_value == "Default" && material_type == "Brick") { k <- (0.1/100)*primary_factor } else if (k_value == "Default" && material_type == "Steel") { k <- (0.2/100)*primary_factor } else if (k_value == "Default" && material_type == "Wood") { k <- (0.4/100)*primary_factor } else { k <- (k_value/100)*primary_factor } c <- c_value # Duty factor ------------------------------------------------------------- duty_factor <- duty_factor_transformer_33_66kv() duty_factor <- duty_factor$duty_factor[which(duty_factor$category == "transformer")] # Location factor ---------------------------------------------------- location_factor <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for building------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor, location_factor) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "EHV Transformer (GM)"), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) # Temperature readings ---------------------------------------------------- mci_temp_readings <- gb_ref$mci_ehv_tf_temp_readings ci_factor_temp_reading <- mci_temp_readings$`Condition Input Factor`[which( mci_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_temp_readings$`Condition Input Cap`[which( mci_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_temp_readings$`Condition Input Collar`[which( mci_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors <- ci_factor_temp_reading measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) # Measured condition cap -------------------------------------------------- measured_condition_cap <- ci_cap_temp_reading # Measured condition collar ----------------------------------------------- measured_condition_collar <- ci_collar_temp_reading # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "EHV Transformer (GM)") factor_divider_1_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) # Building ------------------------------------------------------------- # Coolers/Radiator condition oci_cooler_radiatr_cond <- gb_ref$oci_ehv_tf_cooler_radiatr_cond Oi_collar_coolers_radiator <- oci_cooler_radiatr_cond$`Condition Input Collar`[which( oci_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_cooler_radiatr_cond$`Condition Input Cap`[which( oci_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_cooler_radiatr_cond$`Condition Input Factor`[which( oci_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Kiosk oci_kiosk_cond <- gb_ref$oci_ehv_tf_kiosk_cond Oi_collar_kiosk <- oci_kiosk_cond$`Condition Input Collar`[which( oci_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_kiosk_cond$`Condition Input Cap`[which( oci_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_kiosk_cond$`Condition Input Factor`[which( oci_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_cable_boxes_cond <- gb_ref$oci_ehv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_cable_boxes_cond$`Condition Input Collar`[which( oci_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_cable_boxes_cond$`Condition Input Cap`[which( oci_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_cable_boxes_cond$`Condition Input Factor`[which( oci_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Observed condition factor -------------------------------------- factors_obs <- c(Oi_factor_coolers_radiator, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor <- mmi(factors_obs, factor_divider_1_obs, factor_divider_2_obs, max_no_combined_factors_obs) # Observed condition cap ----------------------------------------- caps_obs <- c(Oi_cap_coolers_radiator, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap <- min(caps_obs) # Observed condition collar --------------------------------------- collars_obs <- c(Oi_collar_coolers_radiator, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar <- max(collars_obs) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- gb_ref$health_score_factor_for_tf factor_divider_1_health <- health_score_factor$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_health <- health_score_factor$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_health <- health_score_factor$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- obs_factor <- observed_condition_modifier$observed_condition_factor mea_factor <- measured_condition_modifier$measured_condition_factor factors_health <- c(obs_factor, mea_factor) health_score_factor <- mmi(factors_health, factor_divider_1_health, factor_divider_2_health, max_no_combined_factors_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_building.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 0.4kV UG PEX Non Pressurised Cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 0.4kV PEX non Pressurised cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_04kv_pex #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for 0.4kV cable pex, 50 years old #' pof_future_cables_04kv_pex( #' utilisation_pct = 80, #' operating_voltage_pct = 60, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.0658, #' c_value = 1.087, #' normal_expected_life = 80, #' simulation_end_year = 100) pof_future_cables_04kv_pex <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.0658, c_value = 1.087, normal_expected_life = 80, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL pseudo_cable_type <- "33kV UG Cable (Non Pressurised)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pseudo_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ # the expected life set to 80 accordingly to p. 33 in "DE-10kV apb kabler CNAIM" expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5 (p. 33 in DE-10kV apb kabler CNAIM), implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_cables_04kv_pex.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 10kV UG Oil Non Preesurised Cables (Armed Paper Lead) #' @description This function calculates the future #' #' annual probability of failure per kilometer for a 10kV Oil non Preesurised cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_10kv_oil #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for 10kV oil cable, 50 years old #' pof_future_cables_10kv_oil( #' utilisation_pct = 80, #' operating_voltage_pct = 60, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.24, #' c_value = 1.087, #' normal_expected_life = 80, #' simulation_end_year = 100) pof_future_cables_10kv_oil <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.24, c_value = 1.087, normal_expected_life = 80, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL pseudo_cable_type <- "33kV UG Cable (Oil)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pseudo_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5 (p. 33 in DE-10kV apb kabler CNAIM), implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_cables_10kv_oil.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 10kV UG PEX Non Pressurised Cables #' @description This function calculates the future #' #' annual probability of failure per kilometer for a 10kV PEX non Pressurised cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_10kv_pex #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for 10kV cable pex, 50 years old #' pof_future_cables_10kv_pex( #' utilisation_pct = 80, #' operating_voltage_pct = 60, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.0658, #' c_value = 1.087, #' normal_expected_life = 80, #' simulation_end_year = 100) pof_future_cables_10kv_pex <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.0658, c_value = 1.087, normal_expected_life = 80, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL pseudo_cable_type <- "33kV UG Cable (Non Pressurised)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pseudo_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5 (p. 33 in DE-10kV apb kabler CNAIM), implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_cables_10kv_pex.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 132kV cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 132kV cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_cables_132kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future probability of failure for 132kV UG Cable (Non Pressurised) #' pof_future_cables_132kv(cable_type = "132kV UG Cable (Non Pressurised)", #' sub_division = "Aluminium sheath - Aluminium conductor", #' utilisation_pct = 75, #' operating_voltage_pct = 50, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' leakage = "Default", #' reliability_factor = "Default", #' age = 1, #' simulation_end_year = 100) pof_future_cables_132kv <- function(cable_type = "132kV UG Cable (Gas)", sub_division = "Aluminium sheath - Aluminium conductor", utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", leakage = "Default", reliability_factor = "Default", age, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Condition Criteria: Leakage Rate` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == cable_type & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- if (asset_category == "132kV UG Cable (Non Pressurised)") { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl("Non Pressurised", gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } else { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl(asset_category, gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "EHV") # EHV and 132kv have identical duty factors # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- asset_category_mmi <- gsub(pattern = "UG", "", asset_category) asset_category_mmi <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", asset_category_mmi, perl=TRUE) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- if (asset_category == "132kV UG Cable (Non Pressurised)") { mci_132kv_cbl_non_pr_shth_test <- gb_ref$mci_132kv_cbl_non_pr_shth_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_132kv_cbl_non_pr_shth_test$`Condition Input Factor` ci_cap_sheath <- mci_132kv_cbl_non_pr_shth_test$`Condition Input Cap` ci_collar_sheath <- mci_132kv_cbl_non_pr_shth_test$`Condition Input Collar` mci_132kv_cbl_non_pr_prtl_disc <- gb_ref$mci_132kv_cbl_non_pr_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) # Partial discharge------------------------------------------------------- ci_factor_partial <- mci_132kv_cbl_non_pr_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_132kv_cbl_non_pr_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_132kv_cbl_non_pr_prtl_disc$`Condition Input Collar` mci_132kv_cbl_non_pr_flt_hist <- gb_ref$mci_132kv_cbl_non_pr_flt_hist # Fault ------------------------------------------------------- for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_132kv_cbl_non_pr_flt_hist$Upper == fault_hist) ci_factor_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_132kv_cbl_non_pr_flt_hist$Lower[n]) & fault_hist < as.numeric(mci_132kv_cbl_non_pr_flt_hist$Upper[n])) { ci_factor_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_132kv_cbl_non_pr_flt_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) } else if (asset_category == "132kV UG Cable (Oil)") { mci_132kv_cable_oil_leakage <- gb_ref$mci_132kv_cable_oil_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_oil <- mci_132kv_cable_oil_leakage$`Condition Input Factor` ci_cap_leakage_oil <- mci_132kv_cable_oil_leakage$`Condition Input Cap` ci_collar_leakage_oil <- mci_132kv_cable_oil_leakage$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_oil measured_condition_cap <- ci_cap_leakage_oil measured_condition_collar <- ci_collar_leakage_oil } else if (asset_category == "132kV UG Cable (Gas)") { mci_132kv_cbl_gas <- gb_ref$mci_132kv_cable_gas_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_gas <- mci_132kv_cbl_gas$`Condition Input Factor` ci_cap_leakage_gas <- mci_132kv_cbl_gas$`Condition Input Cap` ci_collar_leakage_gas <- mci_132kv_cbl_gas$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_gas measured_condition_cap <- ci_cap_leakage_gas measured_condition_collar <- ci_collar_leakage_gas } # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_cables_132kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 30-60kV cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 30-60kV cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_cables_60_30kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future probability of failure for 60kV UG Cable (Non Pressurised) #' pof_future_cables_60_30kv(cable_type = "60kV UG Cable (Non Pressurised)", #' sub_division = "Aluminium sheath - Aluminium conductor", #' utilisation_pct = 75, #' operating_voltage_pct = 50, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' leakage = "Default", #' reliability_factor = "Default", #' age = 1, #' simulation_end_year = 100) pof_future_cables_60_30kv <- function(cable_type = "60kV UG Cable (Gas)", sub_division = "Aluminium sheath - Aluminium conductor", utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", leakage = "Default", reliability_factor = "Default", age, simulation_end_year = 100) { if (cable_type == "30kV UG Cable (Non Pressurised)" ) { cable_type <- "33kV UG Cable (Non Pressurised)" } else if ( cable_type == "30kV UG Cable (Oil)") { cable_type <- "33kV UG Cable (Oil)" } else if ( cable_type == "30kV UG Cable (Gas)") { cable_type <- "33kV UG Cable (Gas)" } else if ( cable_type == "60kV UG Cable (Non Pressurised)") { cable_type <- "66kV UG Cable (Non Pressurised)" } else if ( cable_type == "60kV UG Cable (Oil)") { cable_type <- "66kV UG Cable (Oil)" } else { cable_type <- "66kV UG Cable (Gas)" } `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Condition Criteria: Leakage Rate` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == cable_type & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl("Non Pressurised", gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } else { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl(asset_category, gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "EHV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- asset_category_mmi <- gsub(pattern = "UG", "", asset_category) asset_category_mmi <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", asset_category_mmi, perl=TRUE) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) # Partial discharge------------------------------------------------------- ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist # Fault ------------------------------------------------------- for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) } else if (asset_category == "EHV UG Cable (Oil)") { mci_ehv_cable_oil_leakage <- gb_ref$mci_ehv_cable_oil_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Factor` ci_cap_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Cap` ci_collar_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_oil measured_condition_cap <- ci_cap_leakage_oil measured_condition_collar <- ci_collar_leakage_oil } else if (asset_category == "EHV UG Cable (Gas)") { mci_ehv_cbl_gas <- gb_ref$mci_ehv_cable_gas_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Factor` ci_cap_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Cap` ci_collar_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_gas measured_condition_cap <- ci_cap_leakage_gas measured_condition_collar <- ci_collar_leakage_gas } # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) if (b2 > 2*b1){ b2 <- b1 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_cables_60_30.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 33-66kV cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 33-66kV cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_cables_66_33kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' per annum per kilometre for 33-66kV cables along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future probability of failure for 66kV UG Cable (Non Pressurised) #' pof_future_cables_66_33kv(cable_type = "66kV UG Cable (Non Pressurised)", #' sub_division = "Aluminium sheath - Aluminium conductor", #' utilisation_pct = 75, #' operating_voltage_pct = 50, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' leakage = "Default", #' reliability_factor = "Default", #' age = 1, #' simulation_end_year = 100) pof_future_cables_66_33kv <- function(cable_type = "66kV UG Cable (Gas)", sub_division = "Aluminium sheath - Aluminium conductor", utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", leakage = "Default", reliability_factor = "Default", age, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Condition Criteria: Leakage Rate` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------------ normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == cable_type & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl("Non Pressurised", gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } else { type_k_c <- gb_ref$pof_curve_parameters$`Functional Failure Category`[which( grepl(asset_category, gb_ref$pof_curve_parameters$`Functional Failure Category`, fixed = TRUE) == TRUE )] } k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == type_k_c) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "EHV") # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- asset_category_mmi <- gsub(pattern = "UG", "", asset_category) asset_category_mmi <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", asset_category_mmi, perl=TRUE) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- if (asset_category == "EHV UG Cable (Non Pressurised)") { mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) # partial discharge ------------------------------------------------------ ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist # Fault ------------------------------------------------------------- for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) } else if (asset_category == "EHV UG Cable (Oil)") { mci_ehv_cable_oil_leakage <- gb_ref$mci_ehv_cable_oil_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Factor` ci_cap_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Cap` ci_collar_leakage_oil <- mci_ehv_cable_oil_leakage$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_oil measured_condition_cap <- ci_cap_leakage_oil measured_condition_collar <- ci_collar_leakage_oil } else if (asset_category == "EHV UG Cable (Gas)") { mci_ehv_cbl_gas <- gb_ref$mci_ehv_cable_gas_leakage %>% dplyr::filter( `Condition Criteria: Leakage Rate` == leakage ) ci_factor_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Factor` ci_cap_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Cap` ci_collar_leakage_gas <- mci_ehv_cbl_gas$`Condition Input Collar` # Measured conditions measured_condition_factor <- ci_factor_leakage_gas measured_condition_cap <- ci_cap_leakage_gas measured_condition_collar <- ci_collar_leakage_gas } # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure------------------------------------------------ probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score <- list() year <- seq(from=0,to=simulation_end_year,by=1) future_health_score_list <- list() for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame(year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_cables_66_33kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Poles #' @description This function calculates the future #' annual probability of failure per kilometer for a poles. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_poles #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param pole_decay Numeric Pole Decay #' @return Numeric array. Future probability of failure #' per annum per kilometre for poles. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future annual probability of failure for HV Poles #' pof_future_poles( #' pole_asset_category = "20kV Poles", #' sub_division = "Wood", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("visual_pole_cond" = #' list("Condition Criteria: Pole Top Rot Present?" = "Default"), #' "pole_leaning" = list("Condition Criteria: Pole Leaning?" = "Default"), #' "bird_animal_damage" = #' list("Condition Criteria: Bird/Animal Damage?" = "Default"), #' "top_rot" = list("Condition Criteria: Pole Top Rot Present?" = "Default")), #' pole_decay = "Default", #' reliability_factor = "Default", #' simulation_end_year = 100) pof_future_poles <- function(pole_asset_category = "20kV Poles", sub_division = "Wood", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, pole_decay = "default", observed_condition_inputs, reliability_factor = "Default", simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pole_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == pole_asset_category, `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. pof_asset_category <- "Poles" k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = pole_asset_category, sub_division = sub_division) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) print(initial_health_score) # # Measured conditions # # The table data is same for all poles category # mci_table_names <- list("pole_decay" = "mci_ehv_pole_pole_decay_deter") # Pole decay ---------------------------------------------------- mci_ehv_pole_pole_decay_deter <- gb_ref$mci_ehv_pole_pole_decay_deter ci_factor_pole_decay <- mci_ehv_pole_pole_decay_deter$`Condition Input Factor`[which( mci_ehv_pole_pole_decay_deter$ `Condition Criteria: Degree of Decay/Deterioration` == pole_decay)] ci_cap_pole_decay <- mci_ehv_pole_pole_decay_deter$`Condition Input Cap`[which( mci_ehv_pole_pole_decay_deter$ `Condition Criteria: Degree of Decay/Deterioration` == pole_decay)] ci_collar_pole_decay <- mci_ehv_pole_pole_decay_deter$`Condition Input Collar`[which( mci_ehv_pole_pole_decay_deter$ `Condition Criteria: Degree of Decay/Deterioration` == pole_decay)] # measured condition factor ----------------------------------------------- measured_condition_factor <- ci_factor_pole_decay # The table data is same for all poles category asset_category_mmi <- "HV Poles" # Measured condition cap -------------------------------------------------- measured_condition_cap <- ci_cap_pole_decay # Measured condition collar ----------------------------------------------- measured_condition_collar <- ci_collar_pole_decay # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- # The table data is same for all poles category oci_table_names <- list("visual_pole_cond" = "oci_hv_pole_visual_pole_cond", "pole_leaning" = "oci_ehv_pole_pole_leaning", "bird_animal_damage" = "oci_ehv_pole_bird_animal_damag", "top_rot" = "oci_ehv_pole_pole_top_rot") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_factor) print(observed_condition_modifier) print(measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) print(current_health_score) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_hv_poles.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Meters #' @description This function calculates the future #' annual probability of failure meters. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_meter #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for meter #' pof_future_meter( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 1, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.128, #' c_value = 1.087, #' normal_expected_life = 25, #' simulation_end_year = 100) pof_future_meter <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.128, c_value = 1.087, normal_expected_life = 25, simulation_end_year = 100) { hv_asset_category <- "6.6/11kV CB (GM) Secondary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_meter.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 33-132kV OHL Conductors #' @description This function calculates the future #' annual probability of failure per kilometer 33-132kV OHL conductors. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_ohl_cond_132_66_33kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future annual probability of failure for 66kV OHL (Tower Line) Conductor #' pof_future_ohl_cond_132_66_33kv( #' ohl_conductor = "66kV OHL (Tower Line) Conductor", #' sub_division = "Cu", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' conductor_samp = "Default", #' corr_mon_survey = "Default", #' visual_cond = "Default", #' midspan_joints = "Default", #' reliability_factor = "Default", #' simulation_end_year = 100) pof_future_ohl_cond_132_66_33kv <- function(ohl_conductor = "66kV OHL (Tower Line) Conductor", sub_division = "Cu", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, conductor_samp = "Default", corr_mon_survey = "Default", visual_cond = "Default", midspan_joints = "Default", reliability_factor = "Default", simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Observed Condition` = `Condition Criteria: Corrosion Monitoring Survey Result` = `Condition Criteria: Conductor Sampling Result` = `Condition Criteria: No. of Midspan Joints` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ohl_conductor) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == ohl_conductor & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == generic_term_2) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == generic_term_2) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ohl_conductor) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- if (asset_category == "EHV OHL Conductor (Tower Lines)") { asset_category_mmi <- "EHV Tower Line Conductor" } if (asset_category == "132kV OHL Conductor (Tower Lines)") { asset_category_mmi <- "132kV Tower Line Conductor" } mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Measured inputs----------------------------------------------------------- # Conductor sampling if (asset_category == "132kV OHL Conductor (Tower Lines)") { mci_132kv_twr_line_cond_sampl <- gb_ref$mci_132kv_twr_line_cond_sampl %>% dplyr::filter( `Condition Criteria: Conductor Sampling Result` == conductor_samp ) ci_factor_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Factor` ci_cap_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Cap` ci_collar_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Collar` # Corrosion monitoring survey mci_132kv_twr_line_cond_srvy <- gb_ref$mci_132kv_twr_line_cond_srvy %>% dplyr::filter( `Condition Criteria: Corrosion Monitoring Survey Result` == corr_mon_survey ) ci_factor_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Factor` ci_cap_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Cap` ci_collar_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Collar` } else { mci_ehv_twr_line_cond_sampl <- gb_ref$mci_ehv_twr_line_cond_sampl %>% dplyr::filter( `Condition Criteria: Conductor Sampling Result` == conductor_samp ) ci_factor_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Factor` ci_cap_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Cap` ci_collar_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Collar` # Corrosion monitoring survey mci_ehv_twr_line_cond_srvy <- gb_ref$mci_ehv_twr_line_cond_srvy %>% dplyr::filter( `Condition Criteria: Corrosion Monitoring Survey Result` == corr_mon_survey ) ci_factor_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Factor` ci_cap_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Cap` ci_collar_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Collar` } # Measured conditions factors <- c(ci_factor_cond_samp, ci_factor_cond_srvy) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_cond_samp, ci_cap_cond_srvy) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_cond_samp, ci_collar_cond_srvy) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which( oci_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Observed inputs----------------------------------------------------------- # Visual condition if (asset_category == "132kV OHL Conductor (Tower Lines)") { oci_132kv_twr_line_visual_cond <- gb_ref$oci_132kv_twr_line_visual_cond %>% dplyr::filter( `Condition Criteria: Observed Condition` == visual_cond ) ci_factor_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Factor` ci_cap_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Cap` ci_collar_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Collar` # Midspan joints if (is.numeric(midspan_joints)) { if(midspan_joints < 3) { midspan_joints <- as.character(midspan_joints) } else if (midspan_joints > 2){ midspan_joints <- ">2" } } oci_132kv_twr_line_cond_midspn <- gb_ref$oci_132kv_twr_line_cond_midspn %>% dplyr::filter( `Condition Criteria: No. of Midspan Joints` == midspan_joints ) ci_factor_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Factor` ci_cap_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Cap` ci_collar_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Collar` } else { oci_ehv_twr_line_visal_cond <- gb_ref$oci_ehv_twr_line_visal_cond %>% dplyr::filter( `Condition Criteria: Observed Condition` == visual_cond ) ci_factor_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Factor` ci_cap_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Cap` ci_collar_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Collar` # Midspan joints if (is.numeric(midspan_joints)) { if(midspan_joints < 3) { midspan_joints <- as.character(midspan_joints) } else if (midspan_joints > 2){ midspan_joints <- ">2" } } oci_ehv_twr_cond_midspan_joint <- gb_ref$oci_ehv_twr_cond_midspan_joint %>% dplyr::filter( `Condition Criteria: No. of Midspan Joints` == midspan_joints ) ci_factor_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Factor` ci_cap_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Cap` ci_collar_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Collar` } # Observed conditions factors <- c(ci_factor_visual_cond, ci_factor_midspan_joints) observed_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_visual_cond, ci_cap_midspan_joints) observed_condition_cap <- min(caps) # Observed condition collar ---------------------------------------------- collars <- c(ci_collar_visual_cond, ci_collar_midspan_joints) observed_condition_collar <- max(collars) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_ohl_cond_132_66_33kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 50kV OHL Conductors #' @description This function calculates the future #' annual probability of failure per kilometer 50kV OHL conductors. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ohl_cond_132_66_33kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 50kV OHL (Tower Line) Conductor #' pof_future_ohl_cond_50kv( #' sub_division = "Cu", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' conductor_samp = "Default", #' corr_mon_survey = "Default", #' visual_cond = "Default", #' midspan_joints = "Default", #' reliability_factor = "Default", #' k_value = 0.0080, #' c_value = 1.087, #' normal_expected_life = "Default", #' simulation_end_year = 100) pof_future_ohl_cond_50kv <- function(sub_division = "Cu", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, conductor_samp = "Default", corr_mon_survey = "Default", visual_cond = "Default", midspan_joints = "Default", reliability_factor = "Default", k_value = 0.0080, c_value = 1.087, normal_expected_life = "Default", simulation_end_year = 100) { ohl_conductor <- "66kV OHL (Tower Line) Conductor" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Conductor Sampling Result` = `Condition Criteria: Corrosion Monitoring Survey Result` = `Condition Criteria: Observed Condition` = `Condition Criteria: No. of Midspan Joints` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ohl_conductor) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == ohl_conductor & `Sub-division` == sub_division) %>% dplyr::pull() if (normal_expected_life == "Default") { normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == ohl_conductor & `Sub-division` == sub_division) %>% dplyr::pull() } else { normal_expected_life_cond <- normal_expected_life } # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ohl_conductor) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- if (asset_category == "EHV OHL Conductor (Tower Lines)") { asset_category_mmi <- "EHV Tower Line Conductor" } if (asset_category == "132kV OHL Conductor (Tower Lines)") { asset_category_mmi <- "132kV Tower Line Conductor" } mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Measured inputs----------------------------------------------------------- # Conductor sampling if (asset_category == "132kV OHL Conductor (Tower Lines)") { mci_132kv_twr_line_cond_sampl <- gb_ref$mci_132kv_twr_line_cond_sampl %>% dplyr::filter( `Condition Criteria: Conductor Sampling Result` == conductor_samp ) ci_factor_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Factor` ci_cap_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Cap` ci_collar_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Collar` # Corrosion monitoring survey mci_132kv_twr_line_cond_srvy <- gb_ref$mci_132kv_twr_line_cond_srvy %>% dplyr::filter( `Condition Criteria: Corrosion Monitoring Survey Result` == corr_mon_survey ) ci_factor_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Factor` ci_cap_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Cap` ci_collar_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Collar` } else { mci_ehv_twr_line_cond_sampl <- gb_ref$mci_ehv_twr_line_cond_sampl %>% dplyr::filter( `Condition Criteria: Conductor Sampling Result` == conductor_samp ) ci_factor_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Factor` ci_cap_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Cap` ci_collar_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Collar` # Corrosion monitoring survey mci_ehv_twr_line_cond_srvy <- gb_ref$mci_ehv_twr_line_cond_srvy %>% dplyr::filter( `Condition Criteria: Corrosion Monitoring Survey Result` == corr_mon_survey ) ci_factor_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Factor` ci_cap_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Cap` ci_collar_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Collar` } # Measured conditions factors <- c(ci_factor_cond_samp, ci_factor_cond_srvy) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_cond_samp, ci_cap_cond_srvy) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_cond_samp, ci_collar_cond_srvy) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which( oci_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Observed inputs----------------------------------------------------------- # Visual condition if (asset_category == "132kV OHL Conductor (Tower Lines)") { oci_132kv_twr_line_visual_cond <- gb_ref$oci_132kv_twr_line_visual_cond %>% dplyr::filter( `Condition Criteria: Observed Condition` == visual_cond ) ci_factor_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Factor` ci_cap_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Cap` ci_collar_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Collar` # Midspan joints if (is.numeric(midspan_joints)) { if(midspan_joints < 3) { midspan_joints <- as.character(midspan_joints) } else if (midspan_joints > 2){ midspan_joints <- ">2" } } oci_132kv_twr_line_cond_midspn <- gb_ref$oci_132kv_twr_line_cond_midspn %>% dplyr::filter( `Condition Criteria: No. of Midspan Joints` == midspan_joints ) ci_factor_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Factor` ci_cap_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Cap` ci_collar_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Collar` } else { oci_ehv_twr_line_visal_cond <- gb_ref$oci_ehv_twr_line_visal_cond %>% dplyr::filter( `Condition Criteria: Observed Condition` == visual_cond ) ci_factor_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Factor` ci_cap_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Cap` ci_collar_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Collar` # Midspan joints if (is.numeric(midspan_joints)) { if(midspan_joints < 3) { midspan_joints <- as.character(midspan_joints) } else if (midspan_joints > 2){ midspan_joints <- ">2" } } oci_ehv_twr_cond_midspan_joint <- gb_ref$oci_ehv_twr_cond_midspan_joint %>% dplyr::filter( `Condition Criteria: No. of Midspan Joints` == midspan_joints ) ci_factor_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Factor` ci_cap_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Cap` ci_collar_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Collar` } # Observed conditions factors <- c(ci_factor_visual_cond, ci_factor_midspan_joints) observed_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_visual_cond, ci_cap_midspan_joints) observed_condition_cap <- min(caps) # Observed condition collar ---------------------------------------------- collars <- c(ci_collar_visual_cond, ci_collar_midspan_joints) observed_condition_collar <- max(collars) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_ohl_cond_50kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 50 kV Fittings #' @description This function calculates the future #' annual probability of failure per kilometer for a 50 kV fittings. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100.code #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 50kV fittings #' pof_future_ohl_fittings_50kv( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("insulator_elec_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "insulator_mech_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "conductor_fitting_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "tower_fitting_cond" = #' list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("thermal_imaging" = #' list("Condition Criteria: Thermal Imaging Result" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0096, #' c_value = 1.087, #' normal_expected_life = 40, #' simulation_end_year = 100) pof_future_ohl_fittings_50kv <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0096, c_value = 1.087, normal_expected_life = 40, simulation_end_year = 100) { ehv_asset_category = "66kV Fittings" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ehv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ehv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("thermal_imaging" = "mci_ehv_fittings_thrml_imaging", "ductor_test" = "mci_ehv_fittings_ductor_test") asset_category_mmi <- "EHV Fittings" if(ehv_asset_category == "132kV Fittings"){ asset_category_mmi <- "132kV Fittings" } measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("insulator_elec_cond" = "oci_ehv_fitg_insltr_elect_cond", "insulator_mech_cond" = "oci_ehv_fitg_insltr_mech_cond", "conductor_fitting_cond" = "oci_ehv_cond_fitting_cond", "tower_fitting_cond" = "oci_ehv_twr_fitting_cond") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_ohl_fittings_50kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 0.4kV Pillar #' @description This function calculates the future #' annual probability of failure per kilometer 0.4kV Pillar. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 0.4kV Pillar #' pof_future_pillar_04kv( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_cond" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "compound_leaks" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_cond" = list("Condition Criteria: Observed Condition" = "Default"), #' "insulation" = list("Condition Criteria: Observed Condition" = "Default"), #' "signs_heating" = list("Condition Criteria: Observed Condition" = "Default"), #' "phase_barriers" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("opsal_adequacy" = #' list("Condition Criteria: Operational Adequacy" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0046, #' c_value = 1.087, #' normal_expected_life = 60, #' simulation_end_year = 100) pof_future_pillar_04kv <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0046, c_value = 1.087, normal_expected_life = 60, simulation_end_year = 100){ lv_asset_category <- "LV Pillar (ID)" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = lv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) asset_category_mmi <- get_mmi_lv_switchgear_asset_category(lv_asset_category) # Measured conditions mci_table_names <- list("opsal_adequacy" = "mci_lv_pillar_opsal_adequacy") measured_condition_modifier <- get_measured_conditions_modifier_lv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list( "external_cond" = "oci_lv_pillar_swg_ext_cond", "compound_leaks" = "oci_lv_pillar_compound_leak", "internal_cond" = "oci_lv_pillar_swg_int_cond_op", "insulation" = "oci_lv_pillar_insulation_cond", "signs_heating" = "oci_lv_pillar_signs_heating", "phase_barriers" = "oci_lv_pillar_phase_barrier" ) observed_condition_modifier <- get_observed_conditions_modifier_lv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_pillar_04kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Poles OHL support 50 kV #' @description This function calculates the future #' annual probability of failure per kilometer for a Poles OHL support 50 kV. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param sub_division String Sub Division #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for Poles OHL support 50 kV #' pof_future_poles_ohl_support_50kv( #' sub_division = "Wood", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("visual_pole_cond" = #' list("Condition Criteria: Pole Top Rot Present?" = "Default"), #' "pole_leaning" = list("Condition Criteria: Pole Leaning?" = "Default"), #' "bird_animal_damage" = #' list("Condition Criteria: Bird/Animal Damage?" = "Default"), #' "top_rot" = list("Condition Criteria: Pole Top Rot Present?" = "Default")), #' measured_condition_inputs = #' list("pole_decay" = #' list("Condition Criteria: Degree of Decay/Deterioration" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0285, #' c_value = 1.087, #' normal_expected_life = "Default", #' simulation_end_year = 100) pof_future_poles_ohl_support_50kv <- function(sub_division = "Wood", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0285, c_value = 1.087, normal_expected_life = "Default", simulation_end_year = 100) { pole_asset_category <- "66kV Pole" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pole_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- if (normal_expected_life == "Default") { normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == pole_asset_category, `Sub-division` == sub_division) %>% dplyr::pull() } else { normal_expected_life_cond <- normal_expected_life } # Constants C and K for PoF function -------------------------------------- # POF function asset category. pof_asset_category <- "Poles" k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = pole_asset_category, sub_division = sub_division) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions # The table data is same for all poles category mci_table_names <- list("pole_decay" = "mci_ehv_pole_pole_decay_deter") # The table data is same for all poles category asset_category_mmi <- "EHV Poles" measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- # The table data is same for all poles category oci_table_names <- list("visual_pole_cond" = "oci_ehv_pole_visual_pole_cond", "pole_leaning" = "oci_ehv_pole_pole_leaning", "bird_animal_damage" = "oci_ehv_pole_bird_animal_damag", "top_rot" = "oci_ehv_pole_pole_top_rot") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_poles_ohl_support_50kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Relay #' @description This function calculates the future #' annual probability of failure relay. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @inheritParams pof_future_transformer_04_10kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for relay #' pof_future_relay( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.128, #' c_value = 1.087, #' normal_expected_life = 30, #' simulation_end_year = 100) pof_future_relay <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.128, c_value = 1.087, normal_expected_life = 30, simulation_end_year = 100) { hv_asset_category <- "6.6/11kV CB (GM) Secondary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_relay.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for RTU #' @description This function calculates the future #' annual probability of failure RTU. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for RTU #' pof_future_rtu( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 1, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.128, #' c_value = 1.087, #' normal_expected_life = 20, #' simulation_end_year = 100) pof_future_rtu <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.128, c_value = 1.087, normal_expected_life = 20, simulation_end_year = 100) { hv_asset_category <- "6.6/11kV CB (GM) Secondary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_rtu.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Service Line #' @description This function calculates the future #' annual probability of failure per kilometer for a service line #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @param utilisation_pct Numeric Utilisation Percentage #' @param operating_voltage_pct Numeric Operating Voltage Percentage #' @param sheath_test String Sheath Test #' @param partial_discharge String Partial Discharge #' @param fault_hist String Fault Histogram #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # future annual probability of failure for service line, 50 years old #' pof_future_serviceline( #' utilisation_pct = 80, #' operating_voltage_pct = 60, #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' reliability_factor = "Default", #' age = 50, #' k_value = 0.0329, #' c_value = 1.087, #' normal_expected_life = 75, #' simulation_end_year = 100) pof_future_serviceline <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", reliability_factor = "Default", age, k_value = 0.0329, c_value = 1.087, normal_expected_life = 75, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL pseudo_cable_type <- "33kV UG Cable (Non Pressurised)" sub_division <- "Lead sheath - Copper conductor" # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pseudo_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 # see p. 34 "DE-10kV apb kabler CNAIM" c <- c_value # set to the standard accordingly in CNAIM (2021) and in "DE-10kV apb kabler CNAIM" duty_factor_cable <- duty_factor_cables(utilisation_pct, operating_voltage_pct, voltage_level = "HV") # Expected life ------------------------------ # the expected life set to 80 accordingly to p. 33 in "DE-10kV apb kabler CNAIM" expected_life_years <- expected_life(normal_expected_life, duty_factor_cable, location_factor = 1) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 5.5 (p. 33 in DE-10kV apb kabler CNAIM), implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- asset_category_mmi <- stringr::str_remove(asset_category, pattern = "UG") asset_category_mmi <- stringr::str_squish(asset_category_mmi) mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mmi_type <- mcm_mmi_cal_df$`Asset Category`[which( grepl(asset_category_mmi, mcm_mmi_cal_df$`Asset Category`, fixed = TRUE) == TRUE )] mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_ehv_cbl_non_pr_sheath_test <- gb_ref$mci_ehv_cbl_non_pr_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_ehv_cbl_non_pr_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_ehv_cbl_non_pr_prtl_disch <- gb_ref$mci_ehv_cbl_non_pr_prtl_disch %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Factor` ci_cap_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Cap` ci_collar_partial <- mci_ehv_cbl_non_pr_prtl_disch$`Condition Input Collar` # Fault ------------------------------------------------------- mci_ehv_cbl_non_pr_fault_hist <- gb_ref$mci_ehv_cbl_non_pr_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_ehv_cbl_non_pr_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_ehv_cbl_non_pr_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_ehv_cbl_non_pr_fault_hist$Upper[n])) { ci_factor_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_ehv_cbl_non_pr_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- measured_condition_modifier$measured_condition_factor # Health score cap -------------------------------------------------------- health_score_cap <- measured_condition_modifier$measured_condition_cap # Health score collar ----------------------------------------------------- health_score_collar <- measured_condition_modifier$measured_condition_collar # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health( initial_health_score = initial_health_score, health_score_factor= health_score_modifier$health_score_factor, health_score_cap = health_score_modifier$health_score_cap, health_score_collar = health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_serviceline.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for Submarine Cables #' @description This function calculates the Future #' annual probability of failure per kilometer for submarine cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_submarine_cables #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for 1 km EHV Sub Cable #' pof_future_submarine_cables( #' sub_cable_type = "EHV Sub Cable", #' utilisation_pct = "Default", #' operating_voltage_pct = "Default", #' topography = "Default", #' situation = "Default", #' wind_wave = "Default", #' intensity = "Default", #' landlocked = "no", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' condition_armour = "Default", #' age = 10, #' reliability_factor = "Default", #' simulation_end_year = 100) pof_future_submarine_cables <- function(sub_cable_type = "EHV Sub Cable", utilisation_pct = "Default", operating_voltage_pct = "Default", topography = "Default", situation = "Default", wind_wave = "Default", intensity = "Default", landlocked = "no", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", condition_armour = "Default", age, reliability_factor = "Default", simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Asset Category` = `Condition Criteria` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- if (sub_cable_type == "EHV Sub Cable" || sub_cable_type == "132kV Sub Cable") { sub_marine_col_level <- "EHV" } else { sub_marine_col_level <- "LV & HV" } duty_factor_sub <- duty_factor_cables( utilisation_pct, operating_voltage_pct, voltage_level = sub_marine_col_level) # Location factor --------------------------------------------------------- lf_submarine <- location_factor_sub(topography, situation, wind_wave, intensity, landlocked) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_sub, location_factor = lf_submarine) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == "Submarine Cable"), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_submarine_cbl_sheath_test <- gb_ref$mci_submarine_cbl_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_submarine_cable_prtl_disc <- gb_ref$mci_submarine_cable_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_submarine_cable_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_submarine_cable_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_submarine_cable_prtl_disc$`Condition Input Collar` # Fault ------------------------------------------------------- mci_submarine_cable_fault_hist <- gb_ref$mci_submarine_cable_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_submarine_cable_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_submarine_cable_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_submarine_cable_fault_hist$Upper[n])) { ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "Submarine Cable") factor_divider_1_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`) # External conditions of armour oci_submrn_cable_ext_cond_armr <- gb_ref$oci_submrn_cable_ext_cond_armr %>% dplyr::filter( `Condition Criteria` == condition_armour ) oi_factor <- oci_submrn_cable_ext_cond_armr$`Condition Input Factor` oi_cap <- oci_submrn_cable_ext_cond_armr$`Condition Input Cap` oi_collar <- oci_submrn_cable_ext_cond_armr$`Condition Input Collar` observed_condition_factor <- mmi(oi_factor, factor_divider_1_oi, factor_divider_2_oi, max_no_combined_factors_oi) observed_condition_cap <- oi_cap observed_condition_collar <- oi_collar observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf( observed_condition_modifier$observed_condition_factor, measured_condition_modifier$measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- min(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_submarine_cables.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 10kV Oil Submarine Cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 10kV Oil submarine cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_10kv_pex #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param topography String Topography #' @param sitution String Situation #' @param wind_wave String Wind Wave #' @param intensity String Intensity #' @param landlocked String Land Locked #' @param condition_armour String Condition Armour #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 1 km 10kV Oil Sub Cable #' pof_future_submarine_cables_10kv_oil( #' utilisation_pct = "Default", #' operating_voltage_pct = "Default", #' topography = "Default", #' sitution = "Default", #' wind_wave = "Default", #' intensity = "Default", #' landlocked = "no", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' condition_armour = "Default", #' age = 10, #' reliability_factor = "Default", #' k_value = 0.0202, #' c_value = 1.087, #' normal_expected_life = 60, #' simulation_end_year = 100) pof_future_submarine_cables_10kv_oil <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", topography = "Default", sitution = "Default", wind_wave = "Default", intensity = "Default", landlocked = "no", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", condition_armour = "Default", age, reliability_factor = "Default", k_value = 2.0944, c_value = 1.087, normal_expected_life = 60, simulation_end_year = 100) { sub_cable_type <- "HV Sub Cable" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category`= `K-Value (%)` = `C-Value` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Asset Category` = `Condition Criteria` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- sub_marine_col_level <- "HV" duty_factor_sub <- duty_factor_cables( utilisation_pct, operating_voltage_pct, voltage_level = sub_marine_col_level) # # Location factor --------------------------------------------------------- lf_submarine <- location_factor_sub(topography, sitution, wind_wave, intensity, landlocked) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_sub, lf_submarine) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == "Submarine Cable"), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_submarine_cbl_sheath_test <- gb_ref$mci_submarine_cbl_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_submarine_cable_prtl_disc <- gb_ref$mci_submarine_cable_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_submarine_cable_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_submarine_cable_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_submarine_cable_prtl_disc$`Condition Input Collar` # Fault ------------------------------------------------------- mci_submarine_cable_fault_hist <- gb_ref$mci_submarine_cable_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_submarine_cable_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_submarine_cable_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_submarine_cable_fault_hist$Upper[n])) { ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "Submarine Cable") factor_divider_1_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`) # External conditions of armour oci_submrn_cable_ext_cond_armr <- gb_ref$oci_submrn_cable_ext_cond_armr %>% dplyr::filter( `Condition Criteria` == condition_armour ) oi_factor <- oci_submrn_cable_ext_cond_armr$`Condition Input Factor` oi_cap <- oci_submrn_cable_ext_cond_armr$`Condition Input Cap` oi_collar <- oci_submrn_cable_ext_cond_armr$`Condition Input Collar` observed_condition_factor <- mmi(oi_factor, factor_divider_1_oi, factor_divider_2_oi, max_no_combined_factors_oi) observed_condition_cap <- oi_cap observed_condition_collar <- oi_collar observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf( observed_condition_modifier$observed_condition_factor, measured_condition_modifier$measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- min(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today --------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_submarine_cables_10kv_oil.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 10kV Non Pressurised submarine cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 10kV non pressurised submarine cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_10kv_pex #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param topography String Topography #' @param sitution String Situation #' @param wind_wave String Wind Wave #' @param intensity String Intensity #' @param landlocked String Land Locked #' @param condition_armour String Condition Armour #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 1 km 10kV non pressurised Sub Cable #' pof_future_submarine_cables_10kv_pex( #' utilisation_pct = "Default", #' operating_voltage_pct = "Default", #' topography = "Default", #' sitution = "Default", #' wind_wave = "Default", #' intensity = "Default", #' landlocked = "no", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' condition_armour = "Default", #' age = 10, #' reliability_factor = "Default", #' k_value = 0.0202, #' c_value = 1.087, #' normal_expected_life = 60, #' simulation_end_year = 100) pof_future_submarine_cables_10kv_pex <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", topography = "Default", sitution = "Default", wind_wave = "Default", intensity = "Default", landlocked = "no", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", condition_armour = "Default", age, reliability_factor = "Default", k_value = 0.0202, c_value = 1.087, normal_expected_life = 60, simulation_end_year = 100) { sub_cable_type <- "HV Sub Cable" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category`= `K-Value (%)` = `C-Value` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Asset Category` = `Condition Criteria` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- sub_marine_col_level <- "HV" duty_factor_sub <- duty_factor_cables( utilisation_pct, operating_voltage_pct, voltage_level = sub_marine_col_level) # # Location factor --------------------------------------------------------- lf_submarine <- location_factor_sub(topography, sitution, wind_wave, intensity, landlocked) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_sub, lf_submarine) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == "Submarine Cable"), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_submarine_cbl_sheath_test <- gb_ref$mci_submarine_cbl_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_submarine_cable_prtl_disc <- gb_ref$mci_submarine_cable_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_submarine_cable_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_submarine_cable_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_submarine_cable_prtl_disc$`Condition Input Collar` # Fault ------------------------------------------------------- mci_submarine_cable_fault_hist <- gb_ref$mci_submarine_cable_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_submarine_cable_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_submarine_cable_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_submarine_cable_fault_hist$Upper[n])) { ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "Submarine Cable") factor_divider_1_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`) # External conditions of armour oci_submrn_cable_ext_cond_armr <- gb_ref$oci_submrn_cable_ext_cond_armr %>% dplyr::filter( `Condition Criteria` == condition_armour ) oi_factor <- oci_submrn_cable_ext_cond_armr$`Condition Input Factor` oi_cap <- oci_submrn_cable_ext_cond_armr$`Condition Input Cap` oi_collar <- oci_submrn_cable_ext_cond_armr$`Condition Input Collar` observed_condition_factor <- mmi(oi_factor, factor_divider_1_oi, factor_divider_2_oi, max_no_combined_factors_oi) observed_condition_cap <- oi_cap observed_condition_collar <- oi_collar observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf( observed_condition_modifier$observed_condition_factor, measured_condition_modifier$measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- min(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today --------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_submarine_cables_10kv_pex.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 30kV and 60kV Oil Submarine Cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 30kV and 60kV oil submarine cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_10kv_pex #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param topography String Topography #' @param sitution String Situation #' @param wind_wave String Wind Wave #' @param intensity String Intensity #' @param landlocked String Land Locked #' @param condition_armour String Condition Armour #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' pof_future_submarine_cables_30_60kv_oil( #' utilisation_pct = "Default", #' operating_voltage_pct = "Default", #' topography = "Default", #' sitution = "Default", #' wind_wave = "Default", #' intensity = "Default", #' landlocked = "no", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' condition_armour = "Default", #' age = 10, #' reliability_factor = "Default", #' k_value = 0.0202, #' c_value = 1.087, #' normal_expected_life = 60, #' simulation_end_year = 100) pof_future_submarine_cables_30_60kv_oil <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", topography = "Default", sitution = "Default", wind_wave = "Default", intensity = "Default", landlocked = "no", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", condition_armour = "Default", age, reliability_factor = "Default", k_value = 2.0944, c_value = 1.087, normal_expected_life = 60, simulation_end_year = 100) { sub_cable_type <- "EHV Sub Cable" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category`= `K-Value (%)` = `C-Value` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Asset Category` = `Condition Criteria` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- sub_marine_col_level <- "EHV" duty_factor_sub <- duty_factor_cables( utilisation_pct, operating_voltage_pct, voltage_level = sub_marine_col_level) # # Location factor --------------------------------------------------------- lf_submarine <- location_factor_sub(topography, sitution, wind_wave, intensity, landlocked) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_sub, lf_submarine) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == "Submarine Cable"), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_submarine_cbl_sheath_test <- gb_ref$mci_submarine_cbl_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_submarine_cable_prtl_disc <- gb_ref$mci_submarine_cable_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_submarine_cable_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_submarine_cable_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_submarine_cable_prtl_disc$`Condition Input Collar` # Fault ------------------------------------------------------- mci_submarine_cable_fault_hist <- gb_ref$mci_submarine_cable_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_submarine_cable_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_submarine_cable_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_submarine_cable_fault_hist$Upper[n])) { ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "Submarine Cable") factor_divider_1_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`) # External conditions of armour oci_submrn_cable_ext_cond_armr <- gb_ref$oci_submrn_cable_ext_cond_armr %>% dplyr::filter( `Condition Criteria` == condition_armour ) oi_factor <- oci_submrn_cable_ext_cond_armr$`Condition Input Factor` oi_cap <- oci_submrn_cable_ext_cond_armr$`Condition Input Cap` oi_collar <- oci_submrn_cable_ext_cond_armr$`Condition Input Collar` observed_condition_factor <- mmi(oi_factor, factor_divider_1_oi, factor_divider_2_oi, max_no_combined_factors_oi) observed_condition_cap <- oi_cap observed_condition_collar <- oi_collar observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf( observed_condition_modifier$observed_condition_factor, measured_condition_modifier$measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- min(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today --------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_submarine_cables_30_60kv_oil.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 30kV and 60kV Non Pressurised Submarine Cables #' @description This function calculates the future #' annual probability of failure per kilometer for a 30kV and 60kV Non Pressurised submarine cables #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_cables_10kv_pex #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param topography String Topography #' @param sitution String Situation #' @param wind_wave String Wind Wave #' @param intensity String Intensity #' @param landlocked String Land Locked #' @param condition_armour String Condition Armour #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' pof_future_submarine_cables_30_60kv_pex( #' utilisation_pct = "Default", #' operating_voltage_pct = "Default", #' topography = "Default", #' sitution = "Default", #' wind_wave = "Default", #' intensity = "Default", #' landlocked = "no", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' condition_armour = "Default", #' age = 10, #' reliability_factor = "Default", #' k_value = 0.0202, #' c_value = 1.087, #' normal_expected_life = 60, #' simulation_end_year = 100) pof_future_submarine_cables_30_60kv_pex <- function(utilisation_pct = "Default", operating_voltage_pct = "Default", topography = "Default", sitution = "Default", wind_wave = "Default", intensity = "Default", landlocked = "no", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", condition_armour = "Default", age, reliability_factor = "Default", k_value = 0.0202, c_value = 1.087, normal_expected_life = 60, simulation_end_year = 100) { sub_cable_type <- "EHV Sub Cable" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category`= `K-Value (%)` = `C-Value` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Asset Category` = `Condition Criteria` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- sub_marine_col_level <- "EHV" duty_factor_sub <- duty_factor_cables( utilisation_pct, operating_voltage_pct, voltage_level = sub_marine_col_level) # # Location factor --------------------------------------------------------- lf_submarine <- location_factor_sub(topography, sitution, wind_wave, intensity, landlocked) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_sub, lf_submarine) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == "Submarine Cable"), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_submarine_cbl_sheath_test <- gb_ref$mci_submarine_cbl_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_submarine_cable_prtl_disc <- gb_ref$mci_submarine_cable_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_submarine_cable_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_submarine_cable_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_submarine_cable_prtl_disc$`Condition Input Collar` # Fault ------------------------------------------------------- mci_submarine_cable_fault_hist <- gb_ref$mci_submarine_cable_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_submarine_cable_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_submarine_cable_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_submarine_cable_fault_hist$Upper[n])) { ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "Submarine Cable") factor_divider_1_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`) # External conditions of armour oci_submrn_cable_ext_cond_armr <- gb_ref$oci_submrn_cable_ext_cond_armr %>% dplyr::filter( `Condition Criteria` == condition_armour ) oi_factor <- oci_submrn_cable_ext_cond_armr$`Condition Input Factor` oi_cap <- oci_submrn_cable_ext_cond_armr$`Condition Input Cap` oi_collar <- oci_submrn_cable_ext_cond_armr$`Condition Input Collar` observed_condition_factor <- mmi(oi_factor, factor_divider_1_oi, factor_divider_2_oi, max_no_combined_factors_oi) observed_condition_cap <- oi_cap observed_condition_collar <- oi_collar observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf( observed_condition_modifier$observed_condition_factor, measured_condition_modifier$measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- min(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today --------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_submarine_cables_30_60kv_pex.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 30kV and 60kV Switchgear #' @description This function calculates the future #' annual probability of failure 30kV and 60kV switchgear. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param asset_type String Asset Type #' @param placement String Placement #' @param number_of_operations String Number of Operations #' @param altitude_m String Altitude #' @param distance_from_coast_km String Distance from coast #' @param corrosion_category_index String Corrosion Category Index #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' @param age Numeric Age #' @param reliability_factor String Reliability Factor #' @param k_value Numeric. \code{k_value = 0.0077} by default. This number is #' given in a percentage. The default value is accordingly to the standard #' "DE-10kV apb kabler CNAIM" on p. 34. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 55} by default. #' The default value is accordingly to the standard #' "DE-10kV apb kabler CNAIM" on p. 33. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return Numeric. Current probability of failure #' per annum. #' @export #' @examples #' # Future annual probability of failure for 30kV and 60kV Swicthgear #' pof_future_switchgear_30_60kv( #' asset_type = "30kV", #' number_of_operations = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default"), #' "support_structure" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default"), #' "ir_test" = list("Condition Criteria: IR Test Results" = "Default" )), #' reliability_factor = "Default", #' k_value = "Default", #' c_value = 1.087, #' normal_expected_life = 55, #' simulation_end_year = 100) pof_future_switchgear_30_60kv <- function(asset_type = "30kV", placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = "Default", c_value = 1.087, normal_expected_life = 55, simulation_end_year = 100){ ehv_asset_category <- "33kV RMU" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ehv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. if (k_value == "Default" && asset_type == "30kV" ) { k <- 0.0223/100 } else if (k_value == "Default" && asset_type == "60kV" ) { k <- 0.0512/100 } else { k <- k_value/100 } c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- get_duty_factor_hv_switchgear_primary(number_of_operations) # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ehv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_ehv_swg_partial_discharge", "ductor_test" = "mci_ehv_swg_ductor_test", "oil_test" = "mci_ehv_swg_oil_tests_gas_test", "temp_reading" = "mci_ehv_swg_temp_readings", "trip_test" = "mci_ehv_swg_trip_test", "ir_test"= "mci_ehv_swg_ir_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_ehv_swg_swg_ext_cond", "oil_gas" = "oci_ehv_swg_oil_leak_gas_pr", "thermo_assment" = "oci_ehv_swg_thermo_assessment", "internal_condition" = "oci_ehv_swg_swg_int_cond_ops", "indoor_env" = "oci_ehv_swg_indoor_environ", "support_structure" = "oci_ehv_swg_support_structure") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_switchgear_30_60kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 10kV Switchgear Primary #' @description This function calculates the future #' annual probability of failure 10kV switchgear Primary. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_switchgear_primary_10kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future annual probability of failure for 10 kV Switchgear (GM) Primary #' pof_future_switchgear_primary_10kv( #' number_of_operations = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default"), #' "ir_test" = list("Condition Criteria: IR Test Results" = "Default" )), #' reliability_factor = "Default", #' k_value = 0.0052, #' c_value = 1.087, #' normal_expected_life = 55, #' simulation_end_year = 100) pof_future_switchgear_primary_10kv <- function(placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0052, c_value = 1.087, normal_expected_life = 55, simulation_end_year = 100) { hv_asset_category <- "6.6/11kV CB (GM) Primary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- get_duty_factor_hv_switchgear_primary(number_of_operations) # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_pri_prtl_dischrg", "ductor_test" = "mci_hv_swg_pri_ductor_test", "oil_test" = "mci_hv_swg_pri_oil_tests", "temp_reading" = "mci_hv_swg_pri_temp_reading", "trip_test" = "mci_hv_swg_pri_trip_test", "ir_test"= "mci_hv_swg_pri_ir_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_pri_swg_ext", "oil_gas" = "oci_hv_swg_pri_oil_leak_gas_pr", "thermo_assment" = "oci_hv_swg_pri_thermo_assment", "internal_condition" = "oci_hv_swg_pri_swg_int_cond_op", "indoor_env" = "oci_hv_swg_pri_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_switchgear_primary_10kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 10kV Switchgear Secondary #' @description This function calculates the future #' annual probability of failure 10kV switchgear secondary. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_ehv_fittings #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' pof_future_switchgear_secondary_10kv( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0067, #' c_value = 1.087, #' normal_expected_life = 55, #' simulation_end_year = 100) pof_future_switchgear_secondary_10kv <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0067, c_value = 1.087, normal_expected_life = 55, simulation_end_year = 100) { hv_asset_category <- "6.6/11kV CB (GM) Secondary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_switchgear_secondary_10kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 0.4/10kV Transformers #' @description This function calculates the future #' annual probability of failure for 0.4/10kV Transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_transformer_11_20kv #' @param acidity String Acidity #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @param k_value Numeric. \code{k_value = 0.0069} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 60} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' pof_future_transformer_04_10kv(utilisation_pct = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 20, #' partial_discharge = "Default", #' temperature_reading = "Default", #' observed_condition = "Default", #' reliability_factor = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' k_value = 0.0077, #' c_value = 1.087, #' normal_expected_life = 55, #' simulation_end_year = 100) pof_future_transformer_04_10kv <- function(utilisation_pct = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, partial_discharge = "Default", temperature_reading = "Default", observed_condition = "Default", reliability_factor = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", k_value = 0.0077, c_value = 1.087, normal_expected_life = 55, simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL hv_transformer_type <- "6.6/11kV Transformer (GM)" # this is in order to access tables which are identical to the ones 0.4/10kV transformer is using # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_type <- hv_transformer_type asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_11_20kv(utilisation_pct) # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type) # Expected life for 0.4/10 kV transformer ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_tf_11kv, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Partial discharge ------------------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_hv_tf_partial_discharge ci_factor_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_cap_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_collar_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_hv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors <- c(ci_factor_partial_discharge, oil_test_mod$oil_condition_factor, ci_factor_temp_reading) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) # Measured condition cap -------------------------------------------------- caps <- c(ci_cap_partial_discharge, oil_test_mod$oil_condition_cap, ci_cap_temp_reading) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_partial_discharge, oil_test_mod$oil_condition_collar, ci_collar_temp_reading) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which(oci_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) oci_hv_tf_tf_ext_cond_df <- gb_ref$oci_hv_tf_tf_ext_cond ci_factor_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Factor`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_cap_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Cap`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_collar_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Collar`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] # Observed condition factor ----------------------------------------------- observed_condition_factor <- mmi(factors = ci_factor_ext_cond, factor_divider_1, factor_divider_2, max_no_combined_factors) # Observed condition cap --------------------------------------------- observed_condition_cap <- ci_cap_ext_cond # Observed condition collar --------------------------------------------- observed_condition_collar <- ci_collar_ext_cond # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11kV and 20kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) print(b2) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_transformer_04_10kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 6.6/11kV and 20kV Transformers #' @description This function calculates the future #' annual probability of failure for 6.6/11kV and 20kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_transformer_11_20kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future probability of a 6.6/11 kV transformer #' future_pof_transformer <- #' pof_future_transformer_11_20kv(hv_transformer_type = "6.6/11kV Transformer (GM)", #' utilisation_pct = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 20, #' partial_discharge = "Default", #' temperature_reading = "Default", #' observed_condition = "Default", #' reliability_factor = "Default", #' moisture = "Default", #' oil_acidity = "Default", #' bd_strength = "Default", #' simulation_end_year = 100) pof_future_transformer_11_20kv <- function(hv_transformer_type = "6.6/11kV Transformer (GM)", utilisation_pct = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, partial_discharge = "Default", temperature_reading = "Default", observed_condition = "Default", reliability_factor = "Default", moisture = "Default", oil_acidity = "Default", bd_strength = "Default", simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_type <- hv_transformer_type asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for 6.6/11 kV transformer ------------------------------ normal_expected_life <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_11_20kv(utilisation_pct) # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type) # Expected life for 6.6/11 kV transformer ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_tf_11kv, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Partial discharge ------------------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_hv_tf_partial_discharge ci_factor_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_cap_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_collar_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] # Oil acidity ------------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, oil_acidity, bd_strength) # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_hv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors <- c(ci_factor_partial_discharge, oil_test_mod$oil_condition_factor, ci_factor_temp_reading) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) # Measured condition cap -------------------------------------------------- caps <- c(ci_cap_partial_discharge, oil_test_mod$oil_condition_cap, ci_cap_temp_reading) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_partial_discharge, oil_test_mod$oil_condition_collar, ci_collar_temp_reading) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which(oci_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) oci_hv_tf_tf_ext_cond_df <- gb_ref$oci_hv_tf_tf_ext_cond ci_factor_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Factor`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_cap_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Cap`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_collar_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Collar`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] # Observed condition factor ----------------------------------------------- observed_condition_factor <- mmi(factors = ci_factor_ext_cond, factor_divider_1, factor_divider_2, max_no_combined_factors) # Observed condition cap --------------------------------------------- observed_condition_cap <- ci_cap_ext_cond # Observed condition collar --------------------------------------------- observed_condition_collar <- ci_collar_ext_cond # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life b2 <- beta_2(current_health_score, age) if (b2 > 2*b1){ b2 <- b1*2 } else if (current_health_score == 0.5){ b2 <- b1 } if (current_health_score < 2) { ageing_reduction_factor <- 1 } else if (current_health_score <= 5.5) { ageing_reduction_factor <- ((current_health_score - 2)/7) + 1 } else { ageing_reduction_factor <- 1.5 } # Dynamic part pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score <- current_health_score*exp((b2/ageing_reduction_factor) * t) H <- future_health_Score future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- future_health_Score pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_transformer_11_20kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 132kV Transformers #' @description This function calculates the future #' annual probability of failure for 132kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_transformer_132kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future probability of failure for a 66/10kV transformer #' pof_future_transformer_132kv(transformer_type = "132kV Transformer (GM)", #' year_of_manufacture = 1980, #' utilisation_pct = "Default", #' no_taps = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age_tf = 43, #' age_tc = 43, #' partial_discharge_tf = "Default", #' partial_discharge_tc = "Default", #' temperature_reading = "Default", #' main_tank = "Default", #' coolers_radiator = "Default", #' bushings = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' external_tap = "Default", #' internal_tap = "Default", #' mechnism_cond = "Default", #' diverter_contacts = "Default", #' diverter_braids = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' hydrogen = "Default", #' methane = "Default", #' ethylene = "Default", #' ethane = "Default", #' acetylene = "Default", #' hydrogen_pre = "Default", #' methane_pre = "Default", #' ethylene_pre = "Default", #' ethane_pre = "Default", #' acetylene_pre = "Default", #' furfuraldehyde = "Default", #' reliability_factor = "Default", #' simulation_end_year = 100) pof_future_transformer_132kv <- function(transformer_type = "132kV Transformer (GM)", year_of_manufacture, utilisation_pct = "Default", no_taps = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age_tf, age_tc, partial_discharge_tf = "Default", partial_discharge_tc = "Default", temperature_reading = "Default", main_tank = "Default", coolers_radiator = "Default", bushings = "Default", kiosk = "Default", cable_boxes = "Default", external_tap = "Default", internal_tap = "Default", mechnism_cond = "Default", diverter_contacts = "Default", diverter_braids = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", hydrogen = "Default", methane = "Default", ethylene = "Default", ethane = "Default", acetylene = "Default", hydrogen_pre = "Default", methane_pre = "Default", ethylene_pre = "Default", ethane_pre = "Default", acetylene_pre = "Default", furfuraldehyde = "Default", reliability_factor = "Default", simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for transformer ----------------------------- if (year_of_manufacture < 1980) { sub_division <- "Transformer - Pre 1980" } else { sub_division <- "Transformer - Post 1980" } normal_expected_life_tf <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == sub_division) %>% dplyr::pull() # Normal expected life for tapchanger ----------------------------- normal_expected_life_tc <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == "Tapchanger") %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_33_66kv(utilisation_pct, no_taps) duty_factor_tf <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "transformer")] duty_factor_tc <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "tapchanger")] # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for transformer ------------------------------ expected_life_years_tf <- expected_life(normal_expected_life = normal_expected_life_tf, duty_factor_tf, location_factor_transformer) # Expected life for tapchanger ------------------------------ expected_life_years_tc <- expected_life(normal_expected_life = normal_expected_life_tc, duty_factor_tc, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_tf <- beta_1(expected_life_years_tf) b1_tc <- beta_1(expected_life_years_tc) # Initial health score ---------------------------------------------------- initial_health_score_tf <- initial_health(b1_tf, age_tf) initial_health_score_tc <- initial_health(b1_tc, age_tc) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "132kV Transformer (GM)"), ] factor_divider_1_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Partial discharge transformer ---------------------------------------------- mci_132kv_tf_partial_discharge <- gb_ref$mci_132kv_tf_main_tf_prtl_dis ci_factor_partial_discharge_tf <- mci_132kv_tf_partial_discharge$`Condition Input Factor`[which( mci_132kv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_cap_partial_discharge_tf <- mci_132kv_tf_partial_discharge$`Condition Input Cap`[which( mci_132kv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_collar_partial_discharge_tf <- mci_132kv_tf_partial_discharge$`Condition Input Collar`[which( mci_132kv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] # Partial discharge tapchanger ------------------------------------------------ mci_132kv_tf_partial_discharge_tc <- gb_ref$mci_132kv_tf_tpchngr_prtl_dis ci_factor_partial_discharge_tc <- mci_132kv_tf_partial_discharge_tc$`Condition Input Factor`[which( mci_132kv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_cap_partial_discharge_tc <- mci_132kv_tf_partial_discharge_tc$`Condition Input Cap`[which( mci_132kv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_collar_partial_discharge_tc <- mci_132kv_tf_partial_discharge_tc$`Condition Input Collar`[which( mci_132kv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] # Temperature readings ---------------------------------------------------- mci_132kv_tf_temp_readings <- gb_ref$mci_132kv_tf_temp_readings ci_factor_temp_reading <- mci_132kv_tf_temp_readings$`Condition Input Factor`[which( mci_132kv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_132kv_tf_temp_readings$`Condition Input Cap`[which( mci_132kv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_132kv_tf_temp_readings$`Condition Input Collar`[which( mci_132kv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors_tf <- c(ci_factor_partial_discharge_tf, ci_factor_temp_reading) measured_condition_factor_tf <- mmi(factors_tf, factor_divider_1_tf, factor_divider_2_tf, max_no_combined_factors_tf) measured_condition_factor_tc <- mmi(ci_factor_partial_discharge_tc, factor_divider_1_tc, factor_divider_2_tc, max_no_combined_factors_tc) # Measured condition cap -------------------------------------------------- caps_tf <- c(ci_cap_partial_discharge_tf, ci_cap_temp_reading) measured_condition_cap_tf <- min(caps_tf) measured_condition_cap_tc <- ci_cap_partial_discharge_tc # Measured condition collar ----------------------------------------------- collars_tf <- c(ci_collar_partial_discharge_tf, ci_collar_temp_reading) measured_condition_collar_tf <- max(collars_tf) measured_condition_collar_tc <- ci_collar_partial_discharge_tc # Measured condition modifier --------------------------------------------- measured_condition_modifier_tf <- data.frame(measured_condition_factor_tf, measured_condition_cap_tf, measured_condition_collar_tf) measured_condition_modifier_tc <- data.frame(measured_condition_factor_tc, measured_condition_cap_tc, measured_condition_collar_tc) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "132kV Transformer (GM)") factor_divider_1_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Transformer ------------------------------------------------------------- # Main tank condition oci_132kv_tf_main_tank_cond <- gb_ref$oci_132kv_tf_main_tank_cond Oi_collar_main_tank <- oci_132kv_tf_main_tank_cond$`Condition Input Collar`[which( oci_132kv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_cap_main_tank <- oci_132kv_tf_main_tank_cond$`Condition Input Cap`[which( oci_132kv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_factor_main_tank <- oci_132kv_tf_main_tank_cond$`Condition Input Factor`[which( oci_132kv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] # Coolers/Radiator condition oci_132kv_tf_cooler_radiatr_cond <- gb_ref$oci_132kv_tf_cooler_radtr_cond Oi_collar_coolers_radiator <- oci_132kv_tf_cooler_radiatr_cond$`Condition Input Collar`[which( oci_132kv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_132kv_tf_cooler_radiatr_cond$`Condition Input Cap`[which( oci_132kv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_132kv_tf_cooler_radiatr_cond$`Condition Input Factor`[which( oci_132kv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Bushings oci_132kv_tf_bushings_cond <- gb_ref$oci_132kv_tf_bushings_cond Oi_collar_bushings <- oci_132kv_tf_bushings_cond$`Condition Input Collar`[which( oci_132kv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_cap_bushings <- oci_132kv_tf_bushings_cond$`Condition Input Cap`[which( oci_132kv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_factor_bushings <- oci_132kv_tf_bushings_cond$`Condition Input Factor`[which( oci_132kv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] # Kiosk oci_132kv_tf_kiosk_cond <- gb_ref$oci_132kv_tf_kiosk_cond Oi_collar_kiosk <- oci_132kv_tf_kiosk_cond$`Condition Input Collar`[which( oci_132kv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_132kv_tf_kiosk_cond$`Condition Input Cap`[which( oci_132kv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_132kv_tf_kiosk_cond$`Condition Input Factor`[which( oci_132kv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_132kv_tf_cable_boxes_cond <- gb_ref$oci_132kv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_132kv_tf_cable_boxes_cond$`Condition Input Collar`[which( oci_132kv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_132kv_tf_cable_boxes_cond$`Condition Input Cap`[which( oci_132kv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_132kv_tf_cable_boxes_cond$`Condition Input Factor`[which( oci_132kv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Tapchanger -------------------------------------------------------------- # External condition oci_132kv_tf_tapchanger_ext_cond <- gb_ref$oci_132kv_tf_tapchngr_ext_cond Oi_collar_external_tap <- oci_132kv_tf_tapchanger_ext_cond$`Condition Input Collar`[which( oci_132kv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_cap_external_tap <- oci_132kv_tf_tapchanger_ext_cond$`Condition Input Cap`[which( oci_132kv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_factor_external_tap <- oci_132kv_tf_tapchanger_ext_cond$`Condition Input Factor`[which( oci_132kv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] # Internal condition oci_132kv_tf_int_cond <- gb_ref$oci_132kv_tf_int_cond Oi_collar_internal_tap <- oci_132kv_tf_int_cond$`Condition Input Collar`[which( oci_132kv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_cap_internal_tap <- oci_132kv_tf_int_cond$`Condition Input Cap`[which( oci_132kv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_factor_internal_tap <- oci_132kv_tf_int_cond$`Condition Input Factor`[which( oci_132kv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] # Drive mechanism oci_132kv_tf_drive_mechnism_cond <- gb_ref$oci_132kv_tf_drive_mechsm_cond Oi_collar_mechnism_cond <- oci_132kv_tf_drive_mechnism_cond$`Condition Input Collar`[which( oci_132kv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_cap_mechnism_cond <- oci_132kv_tf_drive_mechnism_cond$`Condition Input Cap`[which( oci_132kv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_factor_mechnism_cond <- oci_132kv_tf_drive_mechnism_cond$`Condition Input Factor`[which( oci_132kv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] # Selecter diverter contacts oci_132kv_tf_cond_select_divrter_cst <- gb_ref$oci_132kv_tf_cond_select_div_c Oi_collar_diverter_contacts <- oci_132kv_tf_cond_select_divrter_cst$`Condition Input Collar`[which( oci_132kv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_cap_diverter_contacts <- oci_132kv_tf_cond_select_divrter_cst$`Condition Input Cap`[which( oci_132kv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_factor_diverter_contacts <- oci_132kv_tf_cond_select_divrter_cst$`Condition Input Factor`[which( oci_132kv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] # Selecter diverter braids oci_132kv_tf_cond_select_divrter_brd <- gb_ref$oci_132kv_tf_cond_select_div_b Oi_collar_diverter_braids <- oci_132kv_tf_cond_select_divrter_brd$`Condition Input Collar`[which( oci_132kv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_cap_diverter_braids <- oci_132kv_tf_cond_select_divrter_brd$`Condition Input Cap`[which( oci_132kv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_factor_diverter_braids <- oci_132kv_tf_cond_select_divrter_brd$`Condition Input Factor`[which( oci_132kv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] # Observed condition factor -------------------------------------- # Transformer factors_tf_obs <- c(Oi_factor_main_tank, Oi_factor_coolers_radiator, Oi_factor_bushings, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor_tf <- mmi(factors_tf_obs, factor_divider_1_tf_obs, factor_divider_2_tf_obs, max_no_combined_factors_tf_obs) # Tapchanger factors_tc_obs <- c(Oi_factor_external_tap, Oi_factor_internal_tap, Oi_factor_mechnism_cond, Oi_factor_diverter_contacts, Oi_factor_diverter_braids) observed_condition_factor_tc <- mmi(factors_tc_obs, factor_divider_1_tc_obs, factor_divider_2_tc_obs, max_no_combined_factors_tc_obs) # Observed condition cap ----------------------------------------- # Transformer caps_tf_obs <- c(Oi_cap_main_tank, Oi_cap_coolers_radiator, Oi_cap_bushings, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap_tf <- min(caps_tf_obs) # Tapchanger caps_tc_obs <- c(Oi_cap_external_tap, Oi_cap_internal_tap, Oi_cap_mechnism_cond, Oi_cap_diverter_contacts, Oi_cap_diverter_braids) observed_condition_cap_tc <- min(caps_tc_obs) # Observed condition collar --------------------------------------- # Transformer collars_tf_obs <- c(Oi_collar_main_tank, Oi_collar_coolers_radiator, Oi_collar_bushings, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar_tf <- max(collars_tf_obs) # Tapchanger collars_tc_obs <- c(Oi_collar_external_tap, Oi_collar_internal_tap, Oi_collar_mechnism_cond, Oi_collar_diverter_contacts, Oi_collar_diverter_braids) observed_condition_collar_tc <- max(collars_tc_obs) # Observed condition modifier --------------------------------------------- # Transformer observed_condition_modifier_tf <- data.frame(observed_condition_factor_tf, observed_condition_cap_tf, observed_condition_collar_tf) # Tapchanger observed_condition_modifier_tc <- data.frame(observed_condition_factor_tc, observed_condition_cap_tc, observed_condition_collar_tc) # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # DGA test modifier ------------------------------------------------------- dga_test_mod <- dga_test_modifier(hydrogen, methane, ethylene, ethane, acetylene, hydrogen_pre, methane_pre, ethylene_pre, ethane_pre, acetylene_pre) # FFA test modifier ------------------------------------------------------- ffa_test_mod <- ffa_test_modifier(furfuraldehyde) # Health score factor --------------------------------------------------- health_score_factor_for_tf <- gb_ref$health_score_factor_for_tf health_score_factor_tapchanger <- gb_ref$health_score_factor_tapchanger # Transformer factor_divider_1_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Tapchanger factor_divider_1_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- # Transformer obs_tf_factor <- observed_condition_modifier_tf$observed_condition_factor_tf mea_tf_factor <- measured_condition_modifier_tf$measured_condition_factor_tf oil_factor <- oil_test_mod$oil_condition_factor dga_factor <- dga_test_mod$dga_test_factor ffa_factor <- ffa_test_mod$ffa_test_factor factors_tf_health <- c(obs_tf_factor, mea_tf_factor, oil_factor, dga_factor, ffa_factor) health_score_factor_tf <- mmi(factors_tf_health, factor_divider_1_tf_health, factor_divider_2_tf_health, max_no_combined_factors_tf_health) # tapchanger obs_tc_factor <- observed_condition_modifier_tc$observed_condition_factor_tc mea_tc_factor <- measured_condition_modifier_tc$measured_condition_factor_tc factors_tc_health <- c(obs_tc_factor, mea_tc_factor, oil_factor) health_score_factor_tc <- mmi(factors_tc_health, factor_divider_1_tc_health, factor_divider_2_tc_health, max_no_combined_factors_tc_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap_tf <- min(observed_condition_modifier_tf$observed_condition_cap_tf, measured_condition_modifier_tf$measured_condition_cap_tf, oil_test_mod$oil_condition_cap, dga_test_mod$dga_test_cap, ffa_test_mod$ffa_test_cap) # Tapchanger health_score_cap_tc <- min(observed_condition_modifier_tc$observed_condition_cap_tc, measured_condition_modifier_tc$measured_condition_cap_tc, oil_test_mod$oil_condition_cap) # Health score collar ----------------------------------------------------- # Transformer health_score_collar_tf <- max(observed_condition_modifier_tf$observed_condition_collar_tf, measured_condition_modifier_tf$measured_condition_collar_tf, oil_test_mod$oil_condition_collar, dga_test_mod$dga_test_collar, ffa_test_mod$ffa_test_collar) # Tapchanger health_score_collar_tc <- max(observed_condition_modifier_tc$observed_condition_collar_tc, measured_condition_modifier_tc$measured_condition_collar_tc, oil_test_mod$oil_condition_collar) # Health score modifier --------------------------------------------------- # transformer health_score_modifier_tf <- data.frame(health_score_factor_tf, health_score_cap_tf, health_score_collar_tf) # Tapchanger health_score_modifier_tc <- data.frame(health_score_factor_tc, health_score_cap_tc, health_score_collar_tc) # Current health score ---------------------------------------------------- # Transformer current_health_score <- max(current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor), current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor)) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life # Transformer current_health_score_tf <- current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor) # Tapchanger current_health_score_tc <- current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor) b2_tf <- beta_2(current_health_score_tf, age = age_tf) b2_tc <- beta_2(current_health_score_tc, age = age_tc) # Transformer if (b2_tf > 2*b1_tf){ b2_tf <- b1_tf } else if (current_health_score_tf == 0.5){ b2_tf <- b1_tf } if (current_health_score_tf < 2) { ageing_reduction_factor_tf <- 1 } else if (current_health_score_tf <= 5.5) { ageing_reduction_factor_tf <- ((current_health_score_tf - 2)/7) + 1 } else { ageing_reduction_factor_tf <- 1.5 } # Tapchanger if (b2_tc > 2*b1_tc){ b2_tc <- b1_tc } else if (current_health_score_tc == 0.5){ b2_tc <- b1_tc } if (current_health_score_tc < 2) { ageing_reduction_factor_tc <- 1 } else if (current_health_score_tc <= 5.5) { ageing_reduction_factor_tc <- ((current_health_score_tc - 2)/7) + 1 } else { ageing_reduction_factor_tc <- 1.5 } # Dynamic bit ------------------------------------------------------------- pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score_tf <- current_health_score_tf*exp((b2_tf/ageing_reduction_factor_tf) * t) future_health_Score_tc <- current_health_score_tc*exp((b2_tc/ageing_reduction_factor_tc) * t) H <- max(future_health_Score_tf, future_health_Score_tc) future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } future_health_score_list[[paste(y)]] <- max(future_health_Score_tf, future_health_Score_tc) pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age_tf for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age_tf + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_transformer_132kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 30/10kV and 60/10kV Transformers #' @description This function calculates the future #' annual probability of failure for 30/10kV and 60/10kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @inheritParams pof_transformer_30_60kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @export #' @examples #' # Future probability of failure for a 60/10kV transformer #' pof_future_transformer_30_60kv(transformer_type = "60kV Transformer (GM)", #' year_of_manufacture = 1980, #' utilisation_pct = "Default", #' no_taps = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age_tf = 43, #' age_tc = 43, #' partial_discharge_tf = "Default", #' partial_discharge_tc = "Default", #' temperature_reading = "Default", #' main_tank = "Default", #' coolers_radiator = "Default", #' bushings = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' external_tap = "Default", #' internal_tap = "Default", #' mechnism_cond = "Default", #' diverter_contacts = "Default", #' diverter_braids = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' hydrogen = "Default", #' methane = "Default", #' ethylene = "Default", #' ethane = "Default", #' acetylene = "Default", #' hydrogen_pre = "Default", #' methane_pre = "Default", #' ethylene_pre = "Default", #' ethane_pre = "Default", #' acetylene_pre = "Default", #' furfuraldehyde = "Default", #' reliability_factor = "Default", #' k_value = 0.454, #' c_value = 1.087, #' normal_expected_life_tf = "Default", #' normal_expected_life_tc = "Default", #' simulation_end_year = 100) pof_future_transformer_30_60kv <- function(transformer_type = "60kV Transformer (GM)", year_of_manufacture, utilisation_pct = "Default", no_taps = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age_tf, age_tc, partial_discharge_tf = "Default", partial_discharge_tc = "Default", temperature_reading = "Default", main_tank = "Default", coolers_radiator = "Default", bushings = "Default", kiosk = "Default", cable_boxes = "Default", external_tap = "Default", internal_tap = "Default", mechnism_cond = "Default", diverter_contacts = "Default", diverter_braids = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", hydrogen = "Default", methane = "Default", ethylene = "Default", ethane = "Default", acetylene = "Default", hydrogen_pre = "Default", methane_pre = "Default", ethylene_pre = "Default", ethane_pre = "Default", acetylene_pre = "Default", furfuraldehyde = "Default", reliability_factor = "Default", k_value = 0.454, c_value = 1.087, normal_expected_life_tf = "Default", normal_expected_life_tc = "Default", simulation_end_year = 100) { if (transformer_type == "30kV Transformer (GM)" ) { transformer_type <- "33kV Transformer (GM)" } else { transformer_type <- "66kV Transformer (GM)" } `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for transformer ----------------------------- if (year_of_manufacture < 1980) { sub_division <- "Transformer - Pre 1980" } else { sub_division <- "Transformer - Post 1980" } if (normal_expected_life_tf == "Default") { normal_expected_life_tf <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == sub_division) %>% dplyr::pull() } else { normal_expected_life_tf <- normal_expected_life_tf } # Normal expected life for tapchanger ----------------------------- if (normal_expected_life_tc == "Default") { normal_expected_life_tc <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == "Tapchanger") %>% dplyr::pull() } else { normal_expected_life_tc <- normal_expected_life_tc } # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_33_66kv(utilisation_pct, no_taps) duty_factor_tf <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "transformer")] duty_factor_tc <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "tapchanger")] # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for transformer ------------------------------ expected_life_years_tf <- expected_life(normal_expected_life = normal_expected_life_tf, duty_factor_tf, location_factor_transformer) # Expected life for tapchanger ------------------------------ expected_life_years_tc <- expected_life(normal_expected_life = normal_expected_life_tc, duty_factor_tc, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_tf <- beta_1(expected_life_years_tf) b1_tc <- beta_1(expected_life_years_tc) # Initial health score ---------------------------------------------------- initial_health_score_tf <- initial_health(b1_tf, age_tf) initial_health_score_tc <- initial_health(b1_tc, age_tc) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "EHV Transformer (GM)"), ] factor_divider_1_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Partial discharge transformer ---------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_ehv_tf_main_tf_prtl_dis ci_factor_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_cap_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_collar_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] # Partial discharge tapchanger ------------------------------------------------ mci_hv_tf_partial_discharge_tc <- gb_ref$mci_ehv_tf_tapchngr_prtl_dis ci_factor_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Factor`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_cap_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Cap`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_collar_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Collar`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_ehv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors_tf <- c(ci_factor_partial_discharge_tf, ci_factor_temp_reading) measured_condition_factor_tf <- mmi(factors_tf, factor_divider_1_tf, factor_divider_2_tf, max_no_combined_factors_tf) measured_condition_factor_tc <- mmi(ci_factor_partial_discharge_tc, factor_divider_1_tc, factor_divider_2_tc, max_no_combined_factors_tc) # Measured condition cap -------------------------------------------------- caps_tf <- c(ci_cap_partial_discharge_tf, ci_cap_temp_reading) measured_condition_cap_tf <- min(caps_tf) measured_condition_cap_tc <- ci_cap_partial_discharge_tc # Measured condition collar ----------------------------------------------- collars_tf <- c(ci_collar_partial_discharge_tf, ci_collar_temp_reading) measured_condition_collar_tf <- max(collars_tf) measured_condition_collar_tc <- ci_collar_partial_discharge_tc # Measured condition modifier --------------------------------------------- measured_condition_modifier_tf <- data.frame(measured_condition_factor_tf, measured_condition_cap_tf, measured_condition_collar_tf) measured_condition_modifier_tc <- data.frame(measured_condition_factor_tc, measured_condition_cap_tc, measured_condition_collar_tc) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "EHV Transformer (GM)") factor_divider_1_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Transformer ------------------------------------------------------------- # Main tank condition oci_ehv_tf_main_tank_cond <- gb_ref$oci_ehv_tf_main_tank_cond Oi_collar_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Collar`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_cap_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Cap`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_factor_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Factor`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] # Coolers/Radiator condition oci_ehv_tf_cooler_radiatr_cond <- gb_ref$oci_ehv_tf_cooler_radiatr_cond Oi_collar_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Collar`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Cap`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Factor`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Bushings oci_ehv_tf_bushings_cond <- gb_ref$oci_ehv_tf_bushings_cond Oi_collar_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Collar`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_cap_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Cap`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_factor_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Factor`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] # Kiosk oci_ehv_tf_kiosk_cond <- gb_ref$oci_ehv_tf_kiosk_cond Oi_collar_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Collar`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Cap`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Factor`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_ehv_tf_cable_boxes_cond <- gb_ref$oci_ehv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Collar`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Cap`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Factor`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Tapchanger -------------------------------------------------------------- # External condition oci_ehv_tf_tapchanger_ext_cond <- gb_ref$oci_ehv_tf_tapchanger_ext_cond Oi_collar_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Collar`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_cap_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Cap`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_factor_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Factor`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] # Internal condition oci_ehv_tf_int_cond <- gb_ref$oci_ehv_tf_int_cond Oi_collar_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Collar`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_cap_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Cap`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_factor_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Factor`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] # Drive mechanism oci_ehv_tf_drive_mechnism_cond <- gb_ref$oci_ehv_tf_drive_mechnism_cond Oi_collar_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Collar`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_cap_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Cap`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_factor_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Factor`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] # Selecter diverter contacts oci_ehv_tf_cond_select_divrter_cst <- gb_ref$oci_ehv_tf_cond_select_div_cts Oi_collar_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_cap_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_factor_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] # Selecter diverter braids oci_ehv_tf_cond_select_divrter_brd <- gb_ref$oci_ehv_tf_cond_select_div_brd Oi_collar_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_cap_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_factor_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] # Observed condition factor -------------------------------------- # Transformer factors_tf_obs <- c(Oi_factor_main_tank, Oi_factor_coolers_radiator, Oi_factor_bushings, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor_tf <- mmi(factors_tf_obs, factor_divider_1_tf_obs, factor_divider_2_tf_obs, max_no_combined_factors_tf_obs) # Tapchanger factors_tc_obs <- c(Oi_factor_external_tap, Oi_factor_internal_tap, Oi_factor_mechnism_cond, Oi_factor_diverter_contacts, Oi_factor_diverter_braids) observed_condition_factor_tc <- mmi(factors_tc_obs, factor_divider_1_tc_obs, factor_divider_2_tc_obs, max_no_combined_factors_tc_obs) # Observed condition cap ----------------------------------------- # Transformer caps_tf_obs <- c(Oi_cap_main_tank, Oi_cap_coolers_radiator, Oi_cap_bushings, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap_tf <- min(caps_tf_obs) # Tapchanger caps_tc_obs <- c(Oi_cap_external_tap, Oi_cap_internal_tap, Oi_cap_mechnism_cond, Oi_cap_diverter_contacts, Oi_cap_diverter_braids) observed_condition_cap_tc <- min(caps_tc_obs) # Observed condition collar --------------------------------------- # Transformer collars_tf_obs <- c(Oi_collar_main_tank, Oi_collar_coolers_radiator, Oi_collar_bushings, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar_tf <- max(collars_tf_obs) # Tapchanger collars_tc_obs <- c(Oi_collar_external_tap, Oi_collar_internal_tap, Oi_collar_mechnism_cond, Oi_collar_diverter_contacts, Oi_collar_diverter_braids) observed_condition_collar_tc <- max(collars_tc_obs) # Observed condition modifier --------------------------------------------- # Transformer observed_condition_modifier_tf <- data.frame(observed_condition_factor_tf, observed_condition_cap_tf, observed_condition_collar_tf) # Tapchanger observed_condition_modifier_tc <- data.frame(observed_condition_factor_tc, observed_condition_cap_tc, observed_condition_collar_tc) # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # DGA test modifier ------------------------------------------------------- dga_test_mod <- dga_test_modifier(hydrogen, methane, ethylene, ethane, acetylene, hydrogen_pre, methane_pre, ethylene_pre, ethane_pre, acetylene_pre) # FFA test modifier ------------------------------------------------------- ffa_test_mod <- ffa_test_modifier(furfuraldehyde) # Health score factor --------------------------------------------------- health_score_factor_for_tf <- gb_ref$health_score_factor_for_tf health_score_factor_tapchanger <- gb_ref$health_score_factor_tapchanger # Transformer factor_divider_1_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Tapchanger factor_divider_1_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- # Transformer obs_tf_factor <- observed_condition_modifier_tf$observed_condition_factor_tf mea_tf_factor <- measured_condition_modifier_tf$measured_condition_factor_tf oil_factor <- oil_test_mod$oil_condition_factor dga_factor <- dga_test_mod$dga_test_factor ffa_factor <- ffa_test_mod$ffa_test_factor factors_tf_health <- c(obs_tf_factor, mea_tf_factor, oil_factor, dga_factor, ffa_factor) health_score_factor_tf <- mmi(factors_tf_health, factor_divider_1_tf_health, factor_divider_2_tf_health, max_no_combined_factors_tf_health) # tapchanger obs_tc_factor <- observed_condition_modifier_tc$observed_condition_factor_tc mea_tc_factor <- measured_condition_modifier_tc$measured_condition_factor_tc factors_tc_health <- c(obs_tc_factor, mea_tc_factor, oil_factor) health_score_factor_tc <- mmi(factors_tc_health, factor_divider_1_tc_health, factor_divider_2_tc_health, max_no_combined_factors_tc_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap_tf <- min(observed_condition_modifier_tf$observed_condition_cap_tf, measured_condition_modifier_tf$measured_condition_cap_tf, oil_test_mod$oil_condition_cap, dga_test_mod$dga_test_cap, ffa_test_mod$ffa_test_cap) # Tapchanger health_score_cap_tc <- min(observed_condition_modifier_tc$observed_condition_cap_tc, measured_condition_modifier_tc$measured_condition_cap_tc, oil_test_mod$oil_condition_cap) # Health score collar ----------------------------------------------------- # Transformer health_score_collar_tf <- max(observed_condition_modifier_tf$observed_condition_collar_tf, measured_condition_modifier_tf$measured_condition_collar_tf, oil_test_mod$oil_condition_collar, dga_test_mod$dga_test_collar, ffa_test_mod$ffa_test_collar) # Tapchanger health_score_collar_tc <- max(observed_condition_modifier_tc$observed_condition_collar_tc, measured_condition_modifier_tc$measured_condition_collar_tc, oil_test_mod$oil_condition_collar) # Health score modifier --------------------------------------------------- # transformer health_score_modifier_tf <- data.frame(health_score_factor_tf, health_score_cap_tf, health_score_collar_tf) # Tapchanger health_score_modifier_tc <- data.frame(health_score_factor_tc, health_score_cap_tc, health_score_collar_tc) # Current health score ---------------------------------------------------- # Transformer current_health_score <- max(current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor), current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor)) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life # Transformer current_health_score_tf <- current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor) # Tapchanger current_health_score_tc <- current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor) b2_tf <- beta_2(current_health_score_tf, age = age_tf) b2_tc <- beta_2(current_health_score_tc, age = age_tc) # Transformer if (b2_tf > 2*b1_tf){ b2_tf <- b1_tf * 2 } else if (current_health_score_tf == 0.5){ b2_tf <- b1_tf } if (current_health_score_tf < 2) { ageing_reduction_factor_tf <- 1 } else if (current_health_score_tf <= 5.5) { ageing_reduction_factor_tf <- ((current_health_score_tf - 2)/7) + 1 } else { ageing_reduction_factor_tf <- 1.5 } # Tapchanger if (b2_tc > 2*b1_tc){ b2_tc <- b1_tc*2 } else if (current_health_score_tc == 0.5){ b2_tc <- b1_tc } if (current_health_score_tc < 2) { ageing_reduction_factor_tc <- 1 } else if (current_health_score_tc <= 5.5) { ageing_reduction_factor_tc <- ((current_health_score_tc - 2)/7) + 1 } else { ageing_reduction_factor_tc <- 1.5 } # Dynamic bit ------------------------------------------------------------- pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score_tf <- current_health_score_tf*exp((b2_tf/ageing_reduction_factor_tf) * t) future_health_Score_tc <- current_health_score_tc*exp((b2_tc/ageing_reduction_factor_tc) * t) H <- max(future_health_Score_tf, future_health_Score_tc) future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- max(future_health_Score_tf, future_health_Score_tc) pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age_tf for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age_tf + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_transformer_30_60kv.R
#' @importFrom magrittr %>% #' @title Future Probability of Failure for 33/10kV and 66/10kV Transformers #' @description This function calculates the future #' annual probability of failure for 33/10kV and 66/10kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @inheritParams pof_transformer_33_66kv #' @param simulation_end_year Numeric. The last year of simulating probability #' of failure. Default is 100. #' @return DataFrame. Future probability of failure #' along with future health score #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Future probability of failure for a 66/10kV transformer #' pof_future_transformer_33_66kv(transformer_type = "66kV Transformer (GM)", #' year_of_manufacture = 1980, #' utilisation_pct = "Default", #' no_taps = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age_tf = 43, #' age_tc = 43, #' partial_discharge_tf = "Default", #' partial_discharge_tc = "Default", #' temperature_reading = "Default", #' main_tank = "Default", #' coolers_radiator = "Default", #' bushings = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' external_tap = "Default", #' internal_tap = "Default", #' mechnism_cond = "Default", #' diverter_contacts = "Default", #' diverter_braids = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' hydrogen = "Default", #' methane = "Default", #' ethylene = "Default", #' ethane = "Default", #' acetylene = "Default", #' hydrogen_pre = "Default", #' methane_pre = "Default", #' ethylene_pre = "Default", #' ethane_pre = "Default", #' acetylene_pre = "Default", #' furfuraldehyde = "Default", #' reliability_factor = "Default", #' simulation_end_year = 100) pof_future_transformer_33_66kv <- function(transformer_type = "66kV Transformer (GM)", year_of_manufacture = 1980, utilisation_pct = "Default", no_taps = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age_tf, age_tc, partial_discharge_tf = "Default", partial_discharge_tc = "Default", temperature_reading = "Default", main_tank = "Default", coolers_radiator = "Default", bushings = "Default", kiosk = "Default", cable_boxes = "Default", external_tap = "Default", internal_tap = "Default", mechnism_cond = "Default", diverter_contacts = "Default", diverter_braids = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", hydrogen = "Default", methane = "Default", ethylene = "Default", ethane = "Default", acetylene = "Default", hydrogen_pre = "Default", methane_pre = "Default", ethylene_pre = "Default", ethane_pre = "Default", acetylene_pre = "Default", furfuraldehyde = "Default", reliability_factor = "Default", simulation_end_year = 100) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Asset Category` = `Sub-division` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for transformer ----------------------------- if (year_of_manufacture < 1980) { sub_division <- "Transformer - Pre 1980" } else { sub_division <- "Transformer - Post 1980" } normal_expected_life_tf <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == sub_division) %>% dplyr::pull() # Normal expected life for tapchanger ----------------------------- normal_expected_life_tc <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == "Tapchanger") %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_33_66kv(utilisation_pct, no_taps) duty_factor_tf <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "transformer")] duty_factor_tc <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "tapchanger")] # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for transformer ------------------------------ expected_life_years_tf <- expected_life(normal_expected_life = normal_expected_life_tf, duty_factor_tf, location_factor_transformer) # Expected life for tapchanger ------------------------------ expected_life_years_tc <- expected_life(normal_expected_life = normal_expected_life_tc, duty_factor_tc, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_tf <- beta_1(expected_life_years_tf) b1_tc <- beta_1(expected_life_years_tc) # Initial health score ---------------------------------------------------- initial_health_score_tf <- initial_health(b1_tf, age_tf) initial_health_score_tc <- initial_health(b1_tc, age_tc) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "EHV Transformer (GM)"), ] factor_divider_1_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Partial discharge transformer ---------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_ehv_tf_main_tf_prtl_dis ci_factor_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_cap_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_collar_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] # Partial discharge tapchanger ------------------------------------------------ mci_hv_tf_partial_discharge_tc <- gb_ref$mci_ehv_tf_tapchngr_prtl_dis ci_factor_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Factor`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_cap_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Cap`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_collar_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Collar`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_ehv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors_tf <- c(ci_factor_partial_discharge_tf, ci_factor_temp_reading) measured_condition_factor_tf <- mmi(factors_tf, factor_divider_1_tf, factor_divider_2_tf, max_no_combined_factors_tf) measured_condition_factor_tc <- mmi(ci_factor_partial_discharge_tc, factor_divider_1_tc, factor_divider_2_tc, max_no_combined_factors_tc) # Measured condition cap -------------------------------------------------- caps_tf <- c(ci_cap_partial_discharge_tf, ci_cap_temp_reading) measured_condition_cap_tf <- min(caps_tf) measured_condition_cap_tc <- ci_cap_partial_discharge_tc # Measured condition collar ----------------------------------------------- collars_tf <- c(ci_collar_partial_discharge_tf, ci_collar_temp_reading) measured_condition_collar_tf <- max(collars_tf) measured_condition_collar_tc <- ci_collar_partial_discharge_tc # Measured condition modifier --------------------------------------------- measured_condition_modifier_tf <- data.frame(measured_condition_factor_tf, measured_condition_cap_tf, measured_condition_collar_tf) measured_condition_modifier_tc <- data.frame(measured_condition_factor_tc, measured_condition_cap_tc, measured_condition_collar_tc) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "EHV Transformer (GM)") factor_divider_1_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Transformer ------------------------------------------------------------- # Main tank condition oci_ehv_tf_main_tank_cond <- gb_ref$oci_ehv_tf_main_tank_cond Oi_collar_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Collar`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_cap_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Cap`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_factor_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Factor`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] # Coolers/Radiator condition oci_ehv_tf_cooler_radiatr_cond <- gb_ref$oci_ehv_tf_cooler_radiatr_cond Oi_collar_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Collar`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Cap`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Factor`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Bushings oci_ehv_tf_bushings_cond <- gb_ref$oci_ehv_tf_bushings_cond Oi_collar_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Collar`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_cap_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Cap`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_factor_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Factor`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] # Kiosk oci_ehv_tf_kiosk_cond <- gb_ref$oci_ehv_tf_kiosk_cond Oi_collar_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Collar`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Cap`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Factor`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_ehv_tf_cable_boxes_cond <- gb_ref$oci_ehv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Collar`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Cap`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Factor`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Tapchanger -------------------------------------------------------------- # External condition oci_ehv_tf_tapchanger_ext_cond <- gb_ref$oci_ehv_tf_tapchanger_ext_cond Oi_collar_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Collar`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_cap_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Cap`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_factor_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Factor`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] # Internal condition oci_ehv_tf_int_cond <- gb_ref$oci_ehv_tf_int_cond Oi_collar_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Collar`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_cap_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Cap`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_factor_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Factor`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] # Drive mechanism oci_ehv_tf_drive_mechnism_cond <- gb_ref$oci_ehv_tf_drive_mechnism_cond Oi_collar_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Collar`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_cap_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Cap`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_factor_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Factor`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] # Selecter diverter contacts oci_ehv_tf_cond_select_divrter_cst <- gb_ref$oci_ehv_tf_cond_select_div_cts Oi_collar_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_cap_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_factor_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] # Selecter diverter braids oci_ehv_tf_cond_select_divrter_brd <- gb_ref$oci_ehv_tf_cond_select_div_brd Oi_collar_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_cap_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_factor_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] # Observed condition factor -------------------------------------- # Transformer factors_tf_obs <- c(Oi_factor_main_tank, Oi_factor_coolers_radiator, Oi_factor_bushings, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor_tf <- mmi(factors_tf_obs, factor_divider_1_tf_obs, factor_divider_2_tf_obs, max_no_combined_factors_tf_obs) # Tapchanger factors_tc_obs <- c(Oi_factor_external_tap, Oi_factor_internal_tap, Oi_factor_mechnism_cond, Oi_factor_diverter_contacts, Oi_factor_diverter_braids) observed_condition_factor_tc <- mmi(factors_tc_obs, factor_divider_1_tc_obs, factor_divider_2_tc_obs, max_no_combined_factors_tc_obs) # Observed condition cap ----------------------------------------- # Transformer caps_tf_obs <- c(Oi_cap_main_tank, Oi_cap_coolers_radiator, Oi_cap_bushings, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap_tf <- min(caps_tf_obs) # Tapchanger caps_tc_obs <- c(Oi_cap_external_tap, Oi_cap_internal_tap, Oi_cap_mechnism_cond, Oi_cap_diverter_contacts, Oi_cap_diverter_braids) observed_condition_cap_tc <- min(caps_tc_obs) # Observed condition collar --------------------------------------- # Transformer collars_tf_obs <- c(Oi_collar_main_tank, Oi_collar_coolers_radiator, Oi_collar_bushings, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar_tf <- max(collars_tf_obs) # Tapchanger collars_tc_obs <- c(Oi_collar_external_tap, Oi_collar_internal_tap, Oi_collar_mechnism_cond, Oi_collar_diverter_contacts, Oi_collar_diverter_braids) observed_condition_collar_tc <- max(collars_tc_obs) # Observed condition modifier --------------------------------------------- # Transformer observed_condition_modifier_tf <- data.frame(observed_condition_factor_tf, observed_condition_cap_tf, observed_condition_collar_tf) # Tapchanger observed_condition_modifier_tc <- data.frame(observed_condition_factor_tc, observed_condition_cap_tc, observed_condition_collar_tc) # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # DGA test modifier ------------------------------------------------------- dga_test_mod <- dga_test_modifier(hydrogen, methane, ethylene, ethane, acetylene, hydrogen_pre, methane_pre, ethylene_pre, ethane_pre, acetylene_pre) # FFA test modifier ------------------------------------------------------- ffa_test_mod <- ffa_test_modifier(furfuraldehyde) # Health score factor --------------------------------------------------- health_score_factor_for_tf <- gb_ref$health_score_factor_for_tf health_score_factor_tapchanger <- gb_ref$health_score_factor_tapchanger # Transformer factor_divider_1_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Tapchanger factor_divider_1_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- # Transformer obs_tf_factor <- observed_condition_modifier_tf$observed_condition_factor_tf mea_tf_factor <- measured_condition_modifier_tf$measured_condition_factor_tf oil_factor <- oil_test_mod$oil_condition_factor dga_factor <- dga_test_mod$dga_test_factor ffa_factor <- ffa_test_mod$ffa_test_factor factors_tf_health <- c(obs_tf_factor, mea_tf_factor, oil_factor, dga_factor, ffa_factor) health_score_factor_tf <- mmi(factors_tf_health, factor_divider_1_tf_health, factor_divider_2_tf_health, max_no_combined_factors_tf_health) # tapchanger obs_tc_factor <- observed_condition_modifier_tc$observed_condition_factor_tc mea_tc_factor <- measured_condition_modifier_tc$measured_condition_factor_tc factors_tc_health <- c(obs_tc_factor, mea_tc_factor, oil_factor) health_score_factor_tc <- mmi(factors_tc_health, factor_divider_1_tc_health, factor_divider_2_tc_health, max_no_combined_factors_tc_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap_tf <- min(observed_condition_modifier_tf$observed_condition_cap_tf, measured_condition_modifier_tf$measured_condition_cap_tf, oil_test_mod$oil_condition_cap, dga_test_mod$dga_test_cap, ffa_test_mod$ffa_test_cap) # Tapchanger health_score_cap_tc <- min(observed_condition_modifier_tc$observed_condition_cap_tc, measured_condition_modifier_tc$measured_condition_cap_tc, oil_test_mod$oil_condition_cap) # Health score collar ----------------------------------------------------- # Transformer health_score_collar_tf <- max(observed_condition_modifier_tf$observed_condition_collar_tf, measured_condition_modifier_tf$measured_condition_collar_tf, oil_test_mod$oil_condition_collar, dga_test_mod$dga_test_collar, ffa_test_mod$ffa_test_collar) # Tapchanger health_score_collar_tc <- max(observed_condition_modifier_tc$observed_condition_collar_tc, measured_condition_modifier_tc$measured_condition_collar_tc, oil_test_mod$oil_condition_collar) # Health score modifier --------------------------------------------------- # transformer health_score_modifier_tf <- data.frame(health_score_factor_tf, health_score_cap_tf, health_score_collar_tf) # Tapchanger health_score_modifier_tc <- data.frame(health_score_factor_tc, health_score_cap_tc, health_score_collar_tc) # Current health score ---------------------------------------------------- # Transformer current_health_score <- max(current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor), current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor)) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) # Future probability of failure ------------------------------------------- # the Health Score of a new asset H_new <- 0.5 # the Health Score of the asset when it reaches its Expected Life # Transformer current_health_score_tf <- current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor) # Tapchanger current_health_score_tc <- current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor) b2_tf <- beta_2(current_health_score_tf, age = age_tf) b2_tc <- beta_2(current_health_score_tc, age = age_tc) # Transformer if (b2_tf > 2*b1_tf){ b2_tf <- b1_tf * 2 } else if (current_health_score_tf == 0.5){ b2_tf <- b1_tf } if (current_health_score_tf < 2) { ageing_reduction_factor_tf <- 1 } else if (current_health_score_tf <= 5.5) { ageing_reduction_factor_tf <- ((current_health_score_tf - 2)/7) + 1 } else { ageing_reduction_factor_tf <- 1.5 } # Tapchanger if (b2_tc > 2*b1_tc){ b2_tc <- b1_tc*2 } else if (current_health_score_tc == 0.5){ b2_tc <- b1_tc } if (current_health_score_tc < 2) { ageing_reduction_factor_tc <- 1 } else if (current_health_score_tc <= 5.5) { ageing_reduction_factor_tc <- ((current_health_score_tc - 2)/7) + 1 } else { ageing_reduction_factor_tc <- 1.5 } # Dynamic bit ------------------------------------------------------------- pof_year <- list() future_health_score_list <- list() year <- seq(from=0,to=simulation_end_year,by=1) for (y in 1:length(year)){ t <- year[y] future_health_Score_tf <- current_health_score_tf*exp((b2_tf/ageing_reduction_factor_tf) * t) future_health_Score_tc <- current_health_score_tc*exp((b2_tc/ageing_reduction_factor_tc) * t) H <- max(future_health_Score_tf, future_health_Score_tc) future_health_score_limit <- 15 if (H > future_health_score_limit){ H <- future_health_score_limit } else if (H < 4) { H <- 4 } future_health_score_list[[paste(y)]] <- max(future_health_Score_tf, future_health_Score_tc) pof_year[[paste(y)]] <- k * (1 + (c * H) + (((c * H)^2) / factorial(2)) + (((c * H)^3) / factorial(3))) } pof_future <- data.frame( year=year, PoF=as.numeric(unlist(pof_year)), future_health_score = as.numeric(unlist(future_health_score_list))) pof_future$age <- NA pof_future$age[1] <- age_tf for(i in 2:nrow(pof_future)) { pof_future$age[i] <- age_tf + i -1 } return(pof_future) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_future_transformer_33_66kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for Poles #' @description This function calculates the current #' annual probability of failure per kilometer Poles #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param pole_asset_category String The type of asset category #' @param sub_division String. Refers to material the pole is made of. #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for HV Poles #' pof_poles( #' pole_asset_category = "20kV Poles", #' sub_division = "Wood", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("visual_pole_cond" = #' list("Condition Criteria: Pole Top Rot Present?" = "Default"), #' "pole_leaning" = list("Condition Criteria: Pole Leaning?" = "Default"), #' "bird_animal_damage" = #' list("Condition Criteria: Bird/Animal Damage?" = "Default"), #' "top_rot" = list("Condition Criteria: Pole Top Rot Present?" = "Default")), #' measured_condition_inputs = #' list("pole_decay" = #' list("Condition Criteria: Degree of Decay/Deterioration" = "Default")), #' reliability_factor = "Default") pof_poles <- function(pole_asset_category = "20kV Poles", sub_division = "Wood", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == pole_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == pole_asset_category, `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. pof_asset_category <- "Poles" k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = pole_asset_category, sub_division = sub_division) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions # The table data is same for all poles category mci_table_names <- list("pole_decay" = "mci_ehv_pole_pole_decay_deter") # The table data is same for all poles category asset_category_mmi <- "HV Poles" measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- # The table data is same for all poles category oci_table_names <- list("visual_pole_cond" = "oci_hv_pole_visual_pole_cond", "pole_leaning" = "oci_ehv_pole_pole_leaning", "bird_animal_damage" = "oci_ehv_pole_bird_animal_damag", "top_rot" = "oci_ehv_pole_pole_top_rot") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_hv_poles.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for HV Switchgear Distribution #' @description This function calculates the current #' annual probability of failure per kilometer HV Switchgear Distribution #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param hv_asset_category String The type of LV asset category #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for HV Swicthgear distribution #' pof_hv_switchgear_distribution( #' hv_asset_category = "6.6/11kV CB (GM) Secondary", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default") pof_hv_switchgear_distribution <- function(hv_asset_category = "6.6/11kV CB (GM) Secondary", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. This is bit different from other tables kc_hv_asset_category <- "HV Switchgear (GM) - Distribution (GM)" k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% kc_hv_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% kc_hv_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) } get_measured_conditions_modifier_hv_switchgear <- function(asset_category_mmi, table_names, measured_condition_inputs, sub_component = NULL){ mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Measured inputs----------------------------------------------------------- factor_dfs <- list() for(table_name in names(table_names)){ gb_ref_table_name <- table_names[[table_name]] mci_table <- gb_ref[[gb_ref_table_name]] mci_table_check_col_name <- names(measured_condition_inputs[[table_name]])[1] mci_table_check_col_val <- measured_condition_inputs[[table_name]][1] row_number <- which(mci_table[[mci_table_check_col_name]] == mci_table_check_col_val) factor_df <- mci_table[row_number,] %>% dplyr::select(c("Condition Input Factor", "Condition Input Cap", "Condition Input Collar")) factor_dfs[[table_name]] <- factor_df } mci_factor_df <- factor_dfs %>% plyr::ldply() measured_condition_factor <- mmi(mci_factor_df[["Condition Input Factor"]], factor_divider_1, factor_divider_2, max_no_combined_factors) measured_condition_cap <- min(mci_factor_df[["Condition Input Cap"]]) measured_condition_collar <- max(mci_factor_df[["Condition Input Collar"]]) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(condition_factor = measured_condition_factor, condition_cap = measured_condition_cap, condition_collar = measured_condition_collar) return(measured_condition_modifier) } get_observed_conditions_modifier_hv_switchgear <- function(asset_category_mmi, table_names, observed_condition_inputs, sub_component = NULL){ oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which( oci_mmi_cal_df$`Asset Category` == asset_category_mmi), ] if(!is.null(sub_component)){ oci_mmi_cal_df <- oci_mmi_cal_df[which( oci_mmi_cal_df$`Subcomponent` == sub_component), ] } factor_divider_1 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Observed inputs----------------------------------------------------------- factor_dfs <- list() for(table_name in names(table_names)){ gb_ref_table_name <- table_names[[table_name]] oci_table <- gb_ref[[gb_ref_table_name]] oci_table_check_col_name <- names(observed_condition_inputs[[table_name]])[1] oci_table_check_col_val <- observed_condition_inputs[[table_name]][1] row_number <- which(oci_table[[oci_table_check_col_name]] == oci_table_check_col_val) factor_df <- oci_table[row_number,] %>% dplyr::select(c("Condition Input Factor", "Condition Input Cap", "Condition Input Collar")) factor_dfs[[table_name]] <- factor_df } oci_factor_df <- factor_dfs %>% plyr::ldply() observed_condition_factor <- mmi(oci_factor_df[["Condition Input Factor"]], factor_divider_1, factor_divider_2, max_no_combined_factors) observed_condition_cap <- min(oci_factor_df[["Condition Input Cap"]]) observed_condition_collar <- max(oci_factor_df[["Condition Input Collar"]]) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(condition_factor = observed_condition_factor, condition_cap = observed_condition_cap, condition_collar = observed_condition_collar) return(observed_condition_modifier) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_hv_switchgear_distribution.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for HV Switchgear Primary #' @description This function calculates the current #' annual probability of failure per kilometer HV Switchgear Primary #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param hv_asset_category String The type of HV asset category #' @param number_of_operations The number of operations for duty factor #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for HV Swicthgear Primary #' pof_hv_switchgear_primary( #' hv_asset_category = "6.6/11kV CB (GM) Primary", #' placement = "Default", #' number_of_operations = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs =list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default"), #' "ir_test" = list("Condition Criteria: IR Test Results" = "Default" )), #' reliability_factor = "Default") pof_hv_switchgear_primary <- function(hv_asset_category = "6.6/11kV CB (GM) Primary", placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- get_duty_factor_hv_switchgear_primary(number_of_operations) # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_pri_prtl_dischrg", "ductor_test" = "mci_hv_swg_pri_ductor_test", "oil_test" = "mci_hv_swg_pri_oil_tests", "temp_reading" = "mci_hv_swg_pri_temp_reading", "trip_test" = "mci_hv_swg_pri_trip_test", "ir_test"= "mci_hv_swg_pri_ir_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_pri_swg_ext", "oil_gas" = "oci_hv_swg_pri_oil_leak_gas_pr", "thermo_assment" = "oci_hv_swg_pri_thermo_assment", "internal_condition" = "oci_hv_swg_pri_swg_int_cond_op", "indoor_env" = "oci_hv_swg_pri_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) } # This function is used for EHV switchgear as well get_duty_factor_hv_switchgear_primary <- function(number_of_operations){ `Number of operations` = NULL duty_factor_df <- gb_ref$duty_factor_lut_switchgear %>% dplyr::filter(`Number of operations` == number_of_operations) return(duty_factor_df$`Duty Factor`) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_hv_switchgear_primary.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for LV switchgear and others #' @description This function calculates the current #' annual probability of failure for LV switchgear and others #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param lv_asset_category String. #' A sting that refers to the specific asset category. Chose between #' \code{lv_asset_category = ("LV Board (WM)", "LV Board (X-type Network) (WM)", #' "LV Circuit Breaker", "LV Pillar (ID)", "LV Pillar (OD at Substation)", #' "LV Pillar (OD not at a Substation)")}. #' See also page 17, table 1 in CNAIM (2021). #' @param lv_asset_category String The type of LV asset category #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for LV Switchgear and other #'pof_lv_switchgear_and_other( #'lv_asset_category = "LV Circuit Breaker", #'placement = "Default", #'altitude_m = "Default", #'distance_from_coast_km = "Default", #'corrosion_category_index = "Default", #'age = 10, #'observed_condition_inputs = #'list("external_condition" = #'list("Condition Criteria: Observed Condition" = "Default")), #'measured_condition_inputs = #'list("operational_adequacy" = #'list("Condition Criteria: Operational Adequacy" = "Default")), #'reliability_factor = "Default") pof_lv_switchgear_and_other <- function(lv_asset_category = "LV Circuit Breaker", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% lv_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% lv_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = lv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) asset_category_mmi <- get_mmi_lv_switchgear_asset_category(lv_asset_category) # Measured conditions mci_table_names <- get_gb_ref_measured_conditions_table_names_lv_switchgear(asset_category_mmi) measured_condition_modifier <- get_measured_conditions_modifier_lv_switchgear(asset_category_mmi, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- get_gb_ref_observed_conditions_table_names_lv_switchgear(asset_category_mmi) observed_condition_modifier <- get_observed_conditions_modifier_lv_switchgear(asset_category_mmi, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) } get_mmi_lv_switchgear_asset_category <- function(asset_category){ if(grepl("LV Board", asset_category, fixed = T)) return("LV Board (WM)") if(grepl("LV Pillar", asset_category, fixed = T)) return("LV Pillars") if(grepl("LV Circuit Breaker", asset_category, fixed = T)) return("LV Circuit Breaker") } get_gb_ref_measured_conditions_table_names_lv_switchgear <- function(asset_category_mmi){ if(asset_category_mmi == "LV Board (WM)") return(list("operational_adequacy" = "mci_lv_board_wm_opsal_adequacy")) if(asset_category_mmi == "LV Pillars") return(list("operational_adequacy" = "mci_lv_pillar_opsal_adequacy")) if(asset_category_mmi == "LV Circuit Breaker") return(list("operational_adequacy" ="mci_lv_cb_opsal_adequacy")) } get_gb_ref_observed_conditions_table_names_lv_switchgear <- function(asset_category_mmi){ if(asset_category_mmi == "LV Board (WM)") return(list("switchgear_external_condition" = "oci_lv_board_swg_ext_cond", "compound_leak" = "oci_lv_board_wm_compound_leak", "switchgear_internal_condition_and_operation" = "oci_lv_board_wm_swg_int_cond")) if(asset_category_mmi == "LV Pillars") return(list("compound_leak" = "oci_lv_pillar_compound_leak", "switchgear_external_condition" = "oci_lv_pillar_swg_ext_cond", "switchgear_internal_condition_and_operation" = "oci_lv_pillar_swg_int_cond_op", "insulation_condition" = "oci_lv_pillar_insulation_cond", "signs_heating" = "oci_lv_pillar_signs_heating", "phase_barrier" = "oci_lv_pillar_phase_barrier" )) if(asset_category_mmi == "LV Circuit Breaker") return(list("external_condition" ="oci_lv_circuit_breakr_ext_cond")) } get_measured_conditions_modifier_lv_switchgear <- function(asset_category_mmi, table_names, measured_condition_inputs){ mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Measured inputs----------------------------------------------------------- factor_dfs <- list() for(table_name in names(table_names)){ gb_ref_table_name <- table_names[[table_name]] mci_table <- gb_ref[[gb_ref_table_name]] mci_table_check_col_name <- names(measured_condition_inputs[[table_name]])[1] mci_table_check_col_val <- measured_condition_inputs[[table_name]][1] row_number <- which(mci_table[[mci_table_check_col_name]] == mci_table_check_col_val) factor_df <- mci_table[row_number,] %>% dplyr::select(c("Condition Input Factor", "Condition Input Cap", "Condition Input Collar")) factor_dfs[[table_name]] <- factor_df } mci_factor_df <- factor_dfs %>% plyr::ldply() measured_condition_factor <- mmi(mci_factor_df[["Condition Input Factor"]], factor_divider_1, factor_divider_2, max_no_combined_factors) measured_condition_cap <- min(mci_factor_df[["Condition Input Cap"]]) measured_condition_collar <- max(mci_factor_df[["Condition Input Collar"]]) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(condition_factor = measured_condition_factor, condition_cap = measured_condition_cap, condition_collar = measured_condition_collar) return(measured_condition_modifier) } get_observed_conditions_modifier_lv_switchgear <- function(asset_category_mmi, table_names, observed_condition_inputs){ oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which( oci_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Observed inputs----------------------------------------------------------- factor_dfs <- list() for(table_name in names(table_names)){ gb_ref_table_name <- table_names[[table_name]] oci_table <- gb_ref[[gb_ref_table_name]] oci_table_check_col_name <- names(observed_condition_inputs[[table_name]])[1] oci_table_check_col_val <- observed_condition_inputs[[table_name]][1] row_number <- which(oci_table[[oci_table_check_col_name]] == oci_table_check_col_val) factor_df <- oci_table[row_number,] %>% dplyr::select(c("Condition Input Factor", "Condition Input Cap", "Condition Input Collar")) factor_dfs[[table_name]] <- factor_df } oci_factor_df <- factor_dfs %>% plyr::ldply() observed_condition_factor <- mmi(oci_factor_df[["Condition Input Factor"]], factor_divider_1, factor_divider_2, max_no_combined_factors) observed_condition_cap <- min(oci_factor_df[["Condition Input Cap"]]) observed_condition_collar <- max(oci_factor_df[["Condition Input Collar"]]) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(condition_factor = observed_condition_factor, condition_cap = observed_condition_cap, condition_collar = observed_condition_collar) return(observed_condition_modifier) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_lv_switchgear_and_other.R
#' @title Current Probability of Failure for LV UGB #' @description This function calculates the current #' annual probability of failure for LV UGB #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param lv_asset_category String. #' A sting that refers to the specific asset category. #' See See page 17, table 1 in CNAIM (2021). #' @param lv_asset_category String The type of LV asset category #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for 10kV OHL (Tower Line) Conductor #'pof_lv_ugb( #'lv_asset_category = "LV UGB", #'placement = "Default", #'altitude_m = "Default", #'distance_from_coast_km = "Default", #'corrosion_category_index = "Default", #'age = 10, #'observed_condition_inputs = #'list("steel_cover_and_pit_condition" = #'list("Condition Criteria: Observed Condition" = "Default"), #'"water_moisture" = list("Condition Criteria: Observed Condition" = "Default"), #'"bell_cond" = list("Condition Criteria: Observed Condition" = "Default"), #'"insulation_cond" = list("Condition Criteria: Observed Condition" = "Default"), #'"signs_heating" = list("Condition Criteria: Observed Condition" = "Default"), #'"phase_barriers" = list("Condition Criteria: Observed Condition" = "Default")), #'measured_condition_inputs = #'list("opsal_adequacy" = #'list("Condition Criteria: Operational Adequacy" = "Default")), #'reliability_factor = "Default") pof_lv_ugb <- function(lv_asset_category = "LV UGB", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == lv_asset_category) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% lv_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% lv_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = lv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("opsal_adequacy" = "mci_lv_ugb_opsal_adequacy") measured_condition_modifier <- get_measured_conditions_modifier_lv_switchgear(lv_asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list( "steel_cover_and_pit_condition" = "oci_lv_ugb_steel_covr_pit_cond", "water_moisture" = "oci_lv_ugb_water_moisture", "bell_cond" = "oci_lv_ugb_bell_cond", "insulation_cond" = "oci_lv_ugb_insulation_cond", "signs_heating" = "oci_lv_ugb_signs_heating", "phase_barriers" = "oci_lv_ugb_phase_barriers" ) observed_condition_modifier <- get_observed_conditions_modifier_lv_switchgear(lv_asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_lv_ugb.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for Meters #' @description This function calculates the current #' annual probability of failure meter #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' @inheritParams current_health #' @param k_value Numeric. \code{k_value = 0.128} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 50} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for meter #' pof_meter( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.128, #' c_value = 1.087, #' normal_expected_life = 25) pof_meter <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.128, c_value = 1.087, normal_expected_life = 25) { hv_asset_category <- "6.6/11kV CB (GM) Secondary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_meter.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 33-132kV OHL Conductors #' @description This function calculates the current #' annual probability of failure per kilometer 33-132kV OHL conductors. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param ohl_conductor String. #' A sting that refers to the specific asset category. #' See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{ohl_conductor = c("33kV OHL (Tower Line) Conductor", #' "66kV OHL (Tower Line) Conductor", "132kV OHL (Tower Line) Conductor")}. #' The default setting is #' \code{ohl_conductor = "66kV OHL (Tower Line) Conductor"}. #' @param sub_division String. Refers to material the conductor is #' made of. Options: #' \code{sub_division = c("ACSR - greased", #' "ACSR - non-greased", #' "AAAC", #' "Cad Cu", #' "Cu", #' "Other") #'}. See page 107, table 20 in CNAIM (2021). #' @inheritParams location_factor #' @param age Numeric. The current age in years of the conductor. #' @param conductor_samp String. Conductor sampling. Options: #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @param corr_mon_survey String. Corrosion monitoring survey. Options: #' \code{corr_mon_survey = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 200 and 202 in CNAIM (2021). #' @param visual_cond String. Visual condition. Options: #' \code{visual_cond = c("No deterioration","Superficial/minor deterioration","Some Deterioration", #' "Substantial Deterioration", "Default")}. #' See page 146, table 140 and 142 in CNAIM (2021). #' @param midspan_joints Integer. Number of midspan joints on the conductor. #' A span includes all conductors in that span. #' See page 146, table 141 and 143 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for 66kV OHL (Tower Line) Conductor #' pof_ohl_cond_132_66_33kv( #' ohl_conductor = "66kV OHL (Tower Line) Conductor", #' sub_division = "Cu", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' conductor_samp = "Default", #' corr_mon_survey = "Default", #' visual_cond = "Default", #' midspan_joints = "Default", #' reliability_factor = "Default") pof_ohl_cond_132_66_33kv <- function(ohl_conductor = "66kV OHL (Tower Line) Conductor", sub_division = "Cu", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, conductor_samp = "Default", corr_mon_survey = "Default", visual_cond = "Default", midspan_joints = "Default", reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Conductor Sampling Result` = `Condition Criteria: Corrosion Monitoring Survey Result` = `Condition Criteria: Observed Condition` = `Condition Criteria: No. of Midspan Joints` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == ohl_conductor) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cond <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == ohl_conductor & `Sub-division` == sub_division) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == generic_term_2) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == generic_term_2) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = ohl_conductor) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cond, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- if (asset_category == "EHV OHL Conductor (Tower Lines)") { asset_category_mmi <- "EHV Tower Line Conductor" } if (asset_category == "132kV OHL Conductor (Tower Lines)") { asset_category_mmi <- "132kV Tower Line Conductor" } mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Measured inputs----------------------------------------------------------- # Conductor sampling if (asset_category == "132kV OHL Conductor (Tower Lines)") { mci_132kv_twr_line_cond_sampl <- gb_ref$mci_132kv_twr_line_cond_sampl %>% dplyr::filter( `Condition Criteria: Conductor Sampling Result` == conductor_samp ) ci_factor_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Factor` ci_cap_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Cap` ci_collar_cond_samp <- mci_132kv_twr_line_cond_sampl$`Condition Input Collar` # Corrosion monitoring survey mci_132kv_twr_line_cond_srvy <- gb_ref$mci_132kv_twr_line_cond_srvy %>% dplyr::filter( `Condition Criteria: Corrosion Monitoring Survey Result` == corr_mon_survey ) ci_factor_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Factor` ci_cap_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Cap` ci_collar_cond_srvy <- mci_132kv_twr_line_cond_srvy$`Condition Input Collar` } else { mci_ehv_twr_line_cond_sampl <- gb_ref$mci_ehv_twr_line_cond_sampl %>% dplyr::filter( `Condition Criteria: Conductor Sampling Result` == conductor_samp ) ci_factor_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Factor` ci_cap_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Cap` ci_collar_cond_samp <- mci_ehv_twr_line_cond_sampl$`Condition Input Collar` # Corrosion monitoring survey mci_ehv_twr_line_cond_srvy <- gb_ref$mci_ehv_twr_line_cond_srvy %>% dplyr::filter( `Condition Criteria: Corrosion Monitoring Survey Result` == corr_mon_survey ) ci_factor_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Factor` ci_cap_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Cap` ci_collar_cond_srvy <- mci_ehv_twr_line_cond_srvy$`Condition Input Collar` } # Measured conditions factors <- c(ci_factor_cond_samp, ci_factor_cond_srvy) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_cond_samp, ci_cap_cond_srvy) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_cond_samp, ci_collar_cond_srvy) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which( oci_mmi_cal_df$`Asset Category` == asset_category_mmi), ] factor_divider_1 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Observed inputs----------------------------------------------------------- # Visual condition if (asset_category == "132kV OHL Conductor (Tower Lines)") { oci_132kv_twr_line_visual_cond <- gb_ref$oci_132kv_twr_line_visual_cond %>% dplyr::filter( `Condition Criteria: Observed Condition` == visual_cond ) ci_factor_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Factor` ci_cap_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Cap` ci_collar_visual_cond <- oci_132kv_twr_line_visual_cond$`Condition Input Collar` # Midspan joints if (is.numeric(midspan_joints)) { if(midspan_joints < 3) { midspan_joints <- as.character(midspan_joints) } else if (midspan_joints > 2){ midspan_joints <- ">2" } } oci_132kv_twr_line_cond_midspn <- gb_ref$oci_132kv_twr_line_cond_midspn %>% dplyr::filter( `Condition Criteria: No. of Midspan Joints` == midspan_joints ) ci_factor_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Factor` ci_cap_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Cap` ci_collar_midspan_joints <- oci_132kv_twr_line_cond_midspn$`Condition Input Collar` } else { oci_ehv_twr_line_visal_cond <- gb_ref$oci_ehv_twr_line_visal_cond %>% dplyr::filter( `Condition Criteria: Observed Condition` == visual_cond ) ci_factor_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Factor` ci_cap_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Cap` ci_collar_visual_cond <- oci_ehv_twr_line_visal_cond$`Condition Input Collar` # Midspan joints if (is.numeric(midspan_joints)) { if(midspan_joints < 3) { midspan_joints <- as.character(midspan_joints) } else if (midspan_joints > 2){ midspan_joints <- ">2" } } oci_ehv_twr_cond_midspan_joint <- gb_ref$oci_ehv_twr_cond_midspan_joint %>% dplyr::filter( `Condition Criteria: No. of Midspan Joints` == midspan_joints ) ci_factor_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Factor` ci_cap_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Cap` ci_collar_midspan_joints <- oci_ehv_twr_cond_midspan_joint$`Condition Input Collar` } # Observed conditions factors <- c(ci_factor_visual_cond, ci_factor_midspan_joints) observed_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_visual_cond, ci_cap_midspan_joints) observed_condition_cap <- min(caps) # Observed condition collar ---------------------------------------------- collars <- c(ci_collar_visual_cond, ci_collar_midspan_joints) observed_condition_collar <- max(collars) # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_ohl_cond_132_66_33kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for Submarine Cables #' @description This function calculates the current #' annual probability of failure per kilometer for submarine cables. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param sub_cable_type String. #' A sting that refers to the specific asset category. #' See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{sub_cable_type = #' c("HV Sub Cable", "EHV Sub Cable", "132kV Sub Cable")}. #' The deafult setting is \code{sub_cable_type = "EHV Sub Cable"}. #' @inheritParams duty_factor_cables #' @inheritParams location_factor_sub #' @param sheath_test String. Indicating the state of the sheath. Options: #' \code{sheath_test = c("Pass", "Failed Minor", "Failed Major", #' "Default")}. See page 158, table 189 in CNAIM (2021). #' @param partial_discharge String. Indicating the level of partial discharge. #' Options: #' \code{partial_discharge = c("Low", "Medium", "High", #' "Default")}. See page 158, table 190 in CNAIM (2021). #' @param fault_hist Numeric. The calculated fault rate for the cable per annum #' per kilometer. A setting of \code{"No historic faults recorded"} #' indicates no fault. See page 158, table 191 in CNAIM (2021). #' @param condition_armour String. Indicating the external condition of the #' submarine cables armour. Options: #' \code{condition_armour = c("Good","Poor","Critical","Default")} #' @inheritParams current_health #' @param situation Situation of the cable #' @param age Numeric. The current age in years of the cable. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for 1 km EHV Sub Cable #' pof_submarine_cables( #' sub_cable_type = "EHV Sub Cable", #' utilisation_pct = "Default", #' operating_voltage_pct = "Default", #' topography = "Default", #' situation = "Default", #' wind_wave = "Default", #' intensity = "Default", #' landlocked = "no", #' sheath_test = "Default", #' partial_discharge = "Default", #' fault_hist = "Default", #' condition_armour = "Default", #' age = 10, #' reliability_factor = "Default" #' ) pof_submarine_cables <- function(sub_cable_type = "EHV Sub Cable", utilisation_pct = "Default", operating_voltage_pct = "Default", topography = "Default", situation = "Default", wind_wave = "Default", intensity = "Default", landlocked = "no", sheath_test = "Default", partial_discharge = "Default", fault_hist = "Default", condition_armour = "Default", age, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category`= `K-Value (%)` = `C-Value` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = `Asset Category` = `Condition Criteria` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_cable <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == sub_cable_type) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- if (sub_cable_type == "EHV Sub Cable" || sub_cable_type == "132kV Sub Cable") { sub_marine_col_level <- "EHV" } else { sub_marine_col_level <- "LV & HV" } duty_factor_sub <- duty_factor_cables( utilisation_pct, operating_voltage_pct, voltage_level = sub_marine_col_level) # Location factor --------------------------------------------------------- lf_submarine <- location_factor_sub(topography, situation, wind_wave, intensity, landlocked) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life_cable, duty_factor_sub, location_factor = lf_submarine) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which( mcm_mmi_cal_df$`Asset Category` == "Submarine Cable"), ] factor_divider_1 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric( mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Sheath test ------------------------------------------------------------- mci_submarine_cbl_sheath_test <- gb_ref$mci_submarine_cbl_sheath_test %>% dplyr::filter( `Condition Criteria: Sheath Test Result` == sheath_test ) ci_factor_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Factor` ci_cap_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Cap` ci_collar_sheath <- mci_submarine_cbl_sheath_test$`Condition Input Collar` # Partial discharge------------------------------------------------------- mci_submarine_cable_prtl_disc <- gb_ref$mci_submarine_cable_prtl_disc %>% dplyr::filter( `Condition Criteria: Partial Discharge Test Result` == partial_discharge ) ci_factor_partial <- mci_submarine_cable_prtl_disc$`Condition Input Factor` ci_cap_partial <- mci_submarine_cable_prtl_disc$`Condition Input Cap` ci_collar_partial <- mci_submarine_cable_prtl_disc$`Condition Input Collar` # Fault ------------------------------------------------------- mci_submarine_cable_fault_hist <- gb_ref$mci_submarine_cable_fault_hist for (n in 2:4) { if (fault_hist == 'Default' || fault_hist == 'No historic faults recorded') { no_row <- which(mci_submarine_cable_fault_hist$Upper == fault_hist) ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[no_row] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[no_row] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[no_row] break } else if (fault_hist >= as.numeric(mci_submarine_cable_fault_hist$Lower[n]) & fault_hist < as.numeric(mci_submarine_cable_fault_hist$Upper[n])) { ci_factor_fault <- mci_submarine_cable_fault_hist$`Condition Input Factor`[n] ci_cap_fault <- mci_submarine_cable_fault_hist$`Condition Input Cap`[n] ci_collar_fault <- mci_submarine_cable_fault_hist$`Condition Input Collar`[n] break } } # Measured conditions factors <- c(ci_factor_sheath, ci_factor_partial, ci_factor_fault) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) caps <- c(ci_cap_sheath, ci_cap_partial, ci_cap_fault) measured_condition_cap <- min(caps) # Measured condition collar ---------------------------------------------- collars <- c(ci_collar_sheath, ci_collar_partial, ci_collar_fault) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed conditions ----------------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "Submarine Cable") factor_divider_1_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors_oi <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`) # External conditions of armour oci_submrn_cable_ext_cond_armr <- gb_ref$oci_submrn_cable_ext_cond_armr %>% dplyr::filter( `Condition Criteria` == condition_armour ) oi_factor <- oci_submrn_cable_ext_cond_armr$`Condition Input Factor` oi_cap <- oci_submrn_cable_ext_cond_armr$`Condition Input Cap` oi_collar <- oci_submrn_cable_ext_cond_armr$`Condition Input Collar` observed_condition_factor <- mmi(oi_factor, factor_divider_1_oi, factor_divider_2_oi, max_no_combined_factors_oi) observed_condition_cap <- oi_cap observed_condition_collar <- oi_collar observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf( observed_condition_modifier$observed_condition_factor, measured_condition_modifier$measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$observed_condition_cap, measured_condition_modifier$measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- min(observed_condition_modifier$observed_condition_collar, measured_condition_modifier$measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11 kV transformer today --------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_submarine_cables.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 10 kV Switchgear (GM) Primary #' @description This function calculates the current #' annual probability of failure 10 kV Switchgear (GM) Primary #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param number_of_operations The number of operations for duty factor #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. #' A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' @inheritParams current_health #' @param k_value Numeric. \code{k_value = 0.0052} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 55} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for 10 kV Switchgear (GM) Primary #' pof_switchgear_primary_10kv( #' number_of_operations = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default"), #' "ir_test" = list("Condition Criteria: IR Test Results" = "Default" )), #' reliability_factor = "Default", #' k_value = 0.0052, #' c_value = 1.087, #' normal_expected_life = 55) pof_switchgear_primary_10kv <- function(placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0052, c_value = 1.087, normal_expected_life = 55) { hv_asset_category <- "6.6/11kV CB (GM) Primary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- get_duty_factor_hv_switchgear_primary(number_of_operations) # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_pri_prtl_dischrg", "ductor_test" = "mci_hv_swg_pri_ductor_test", "oil_test" = "mci_hv_swg_pri_oil_tests", "temp_reading" = "mci_hv_swg_pri_temp_reading", "trip_test" = "mci_hv_swg_pri_trip_test", "ir_test"= "mci_hv_swg_pri_ir_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_pri_swg_ext", "oil_gas" = "oci_hv_swg_pri_oil_leak_gas_pr", "thermo_assment" = "oci_hv_swg_pri_thermo_assment", "internal_condition" = "oci_hv_swg_pri_swg_int_cond_op", "indoor_env" = "oci_hv_swg_pri_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_switchgear_primary_10kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 10kV Switchgear secondary #' @description This function calculates the current #' annual probability of failure 10kV Switchgear secondary #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param measured_condition_inputs Named list observed_conditions_input #' @param observed_condition_inputs Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' @inheritParams current_health #' @param k_value Numeric. \code{k_value = 0.0067} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 55} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for 10kV Swicthgear secondary #' pof_switchgear_secondary_10kV( #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' observed_condition_inputs = #' list("external_condition" = #' list("Condition Criteria: Observed Condition" = "Default"), #' "oil_gas" = list("Condition Criteria: Observed Condition" = "Default"), #' "thermo_assment" = list("Condition Criteria: Observed Condition" = "Default"), #' "internal_condition" = list("Condition Criteria: Observed Condition" = "Default"), #' "indoor_env" = list("Condition Criteria: Observed Condition" = "Default")), #' measured_condition_inputs = #' list("partial_discharge" = #' list("Condition Criteria: Partial Discharge Test Results" = "Default"), #' "ductor_test" = list("Condition Criteria: Ductor Test Results" = "Default"), #' "oil_test" = list("Condition Criteria: Oil Test Results" = "Default"), #' "temp_reading" = list("Condition Criteria: Temperature Readings" = "Default"), #' "trip_test" = list("Condition Criteria: Trip Timing Test Result" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0067, #' c_value = 1.087, #' normal_expected_life = 55) pof_switchgear_secondary_10kV <- function(placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, measured_condition_inputs, observed_condition_inputs, reliability_factor = "Default", k_value = 0.0067, c_value = 1.087, normal_expected_life = 55) { hv_asset_category <- "6.6/11kV CB (GM) Secondary" `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == hv_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_cond <- 1 # Location factor ---------------------------------------------------- location_factor_cond <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = hv_asset_category) # Expected life ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_cond, location_factor_cond) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) # Measured conditions mci_table_names <- list("partial_discharge" = "mci_hv_swg_distr_prtl_dischrg", "ductor_test" = "mci_hv_swg_distr_ductor_test", "oil_test" = "mci_hv_swg_distr_oil_test", "temp_reading" = "mci_hv_swg_distr_temp_reading", "trip_test" = "mci_hv_swg_distr_trip_test") measured_condition_modifier <- get_measured_conditions_modifier_hv_switchgear(asset_category, mci_table_names, measured_condition_inputs) # Observed conditions ----------------------------------------------------- oci_table_names <- list("external_condition" = "oci_hv_swg_dist_swg_ext_cond", "oil_gas" = "oci_hv_swg_dist_oil_lek_gas_pr", "thermo_assment" = "oci_hv_swg_dist_thermo_assment", "internal_condition" = "oci_hv_swg_dist_swg_int_cond", "indoor_env" = "oci_hv_swg_dist_indoor_environ") observed_condition_modifier <- get_observed_conditions_modifier_hv_switchgear(asset_category, oci_table_names, observed_condition_inputs) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_modifier$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_modifier$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_modifier$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_switchgear_secondary_10kv.R
#' @title Current Probability of Failure for Towers OHL support 50kV #' @description This function calculates the current #' annual probability of failure per kilometer EHV for Towers OHL support 50kV #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param number_of_operations Numeric Number of operations for the tower #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. #' A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param foundation_type String. Foundation type of the tower #' \code{foundation_type = c("Foundation - Fully Encased Concrete", #' "Foundation - Earth Grillage")} #' @param paint_type String. Paint type of the tower #' \code{foundation_type = c(Paint System - Galvanising, Paint System - Paint )} #' @param observed_condition_inputs_steelwork Named list observed_conditions_input #' @param observed_condition_inputs_paint Named list observed_conditions_input #' @param observed_condition_inputs_foundation Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' @inheritParams current_health #' @param k_value Numeric. \code{k_value = 0.0545} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = "Default"} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current annual probability of failure for Towers #' pof_tower_ohl_support_50kv( #' number_of_operations = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' paint_type = "Paint System - Galvanising", #' foundation_type = "Foundation - Earth Grillage", #' observed_condition_inputs_steelwork = #' list("tower_legs" = list("Condition Criteria: Observed Condition" = "Default"), #' "tower_bracings" = list("Condition Criteria: Observed Condition" = "Default"), #' "tower_crossarms" = list("Condition Criteria: Observed Condition" = "Default"), #' "tower_peak" = list("Condition Criteria: Observed Condition" = "Default")), #' observed_condition_inputs_paint = #' list("paintwork_cond" = list("Condition Criteria: Observed Condition" = "Default")), #' observed_condition_inputs_foundation = #' list("foundation_cond" = list("Condition Criteria: Observed Condition" = "Default")), #' reliability_factor = "Default", #' k_value = 0.0545, #' c_value = 1.087, #' normal_expected_life = "Default") pof_tower_ohl_support_50kv <- function(foundation_type = "Foundation - Fully Encased Concrete", paint_type = "Paint System - Paint", placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, observed_condition_inputs_steelwork, observed_condition_inputs_paint, observed_condition_inputs_foundation, reliability_factor = "Default", k_value = 0.0545, c_value = 1.087, normal_expected_life = "Default") { tower_asset_category <- "66kV Tower" `Asset Register Category` = `Health Index Asset Category` = `Sub-division` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == tower_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- if (normal_expected_life == "Default") { normal_expected_life_steelwork <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == tower_asset_category, `Sub-division` == "Steelwork") %>% dplyr::pull() normal_expected_life_foundation <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == tower_asset_category, `Sub-division` == foundation_type) %>% dplyr::pull() normal_expected_life_paint <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == tower_asset_category, `Sub-division` == paint_type) %>% dplyr::pull() } else { normal_expected_life_steelwork <- normal_expected_life normal_expected_life_foundation <- normal_expected_life normal_expected_life_paint <- normal_expected_life } # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ---------------------------------------------------- duty_factor <- 1 # Location factor ---------------------------------------------------- location_factor <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = tower_asset_category) # Expected life for structure ------------------------------ expected_life_years_steelwork <- expected_life(normal_expected_life = normal_expected_life_steelwork, duty_factor, location_factor) # Expected life for paint ------------------------------ expected_life_years_foundation <- expected_life(normal_expected_life = normal_expected_life_foundation, duty_factor, location_factor) # Expected life for paint ------------------------------ expected_life_years_paint <- expected_life(normal_expected_life = normal_expected_life_paint, duty_factor, location_factor) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_steelwork <- beta_1(expected_life_years_steelwork) b1_foundation <- beta_1(expected_life_years_foundation) b1_paint <- beta_1(expected_life_years_paint) # Initial health score ---------------------------------------------------- initial_health_score_steelwork <- initial_health(b1_steelwork, age) initial_health_score_foundation <- initial_health(b1_foundation, age) initial_health_score_paint <- initial_health(b1_paint, age) # Measured conditions measured_condition_modifier <- data.frame(condition_factor = 1, condition_cap = 10, condition_collar = 0.5) # Observed conditions ----------------------------------------------------- # The table data is same for all towers category oci_table_names_steelwork <- list("tower_legs" = "oci_ehv_tower_tower_legs", "tower_bracings" = "oci_ehv_tower_bracings", "tower_crossarms" = "oci_ehv_tower_crossarms", "tower_peak" = "oci_ehv_tower_peak") oci_table_names_paint <- list("paintwork_cond" = "oci_ehv_tower_paintwork_cond") oci_table_names_foundation <- list("foundation_cond" = "oci_ehv_tower_foundation_cond") observed_condition_modifier_steelwork <- get_observed_conditions_modifier_hv_switchgear("EHV Towers", oci_table_names_steelwork, observed_condition_inputs_steelwork, "Tower Steelwork") observed_condition_modifier_paint <- get_observed_conditions_modifier_hv_switchgear("EHV Towers", oci_table_names_paint, observed_condition_inputs_paint, "Tower Paintwork") observed_condition_modifier_foundation <- get_observed_conditions_modifier_hv_switchgear("EHV Towers", oci_table_names_foundation, observed_condition_inputs_foundation, "Foundations") # Health score factor --------------------------------------------------- health_score_factor_steelwork <- health_score_excl_ehv_132kv_tf(observed_condition_modifier_steelwork$condition_factor, measured_condition_modifier$condition_factor) health_score_factor_paint <- health_score_excl_ehv_132kv_tf(observed_condition_modifier_paint$condition_factor, measured_condition_modifier$condition_factor) health_score_factor_foundation <- health_score_excl_ehv_132kv_tf(observed_condition_modifier_foundation$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap_steelwork <- min(observed_condition_modifier_steelwork$condition_cap, measured_condition_modifier$condition_cap) health_score_cap_paint <- min(observed_condition_modifier_paint$condition_cap, measured_condition_modifier$condition_cap) health_score_cap_foundation <- min(observed_condition_modifier_foundation$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar_steelowrk <- max(observed_condition_modifier_steelwork$condition_collar, measured_condition_modifier$condition_collar) health_score_collar_paint <- max(observed_condition_modifier_paint$condition_collar, measured_condition_modifier$condition_collar) health_score_collar_foundation <- max(observed_condition_modifier_foundation$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier_steelwork <- data.frame(health_score_factor_steelwork, health_score_cap_steelwork, health_score_collar_steelowrk) health_score_modifier_paint <- data.frame(health_score_factor_paint, health_score_cap_paint, health_score_collar_paint) health_score_modifier_foundation <- data.frame(health_score_factor_foundation, health_score_cap_foundation, health_score_collar_foundation) # Current health score ---------------------------------------------------- current_health_score_steelwork <- current_health(initial_health_score_steelwork, health_score_modifier_steelwork$health_score_factor, health_score_modifier_steelwork$health_score_cap, health_score_modifier_steelwork$health_score_collar, reliability_factor = reliability_factor) current_health_score_paint <- current_health(initial_health_score_paint, health_score_modifier_paint$health_score_factor, health_score_modifier_paint$health_score_cap, health_score_modifier_paint$health_score_collar, reliability_factor = reliability_factor) current_health_score_foundation <- current_health(initial_health_score_foundation, health_score_modifier_foundation$health_score_factor, health_score_modifier_foundation$health_score_cap, health_score_modifier_foundation$health_score_collar, reliability_factor = reliability_factor) current_health_score_paint <- min(current_health_score_paint, 6.4) current_health_score <- max(current_health_score_foundation, current_health_score_steelwork, current_health_score_paint) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_tower_ohl_support_50kv.R
#' @title Current Probability of Failure for Towers #' @description This function calculates the current #' annual probability of failure per kilometer EHV Switchgear #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param tower_asset_category String The type of Tower asset category #' @param number_of_operations Numeric Number of operations for the tower #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. See page 111, #' table 23 in CNAIM (2021). A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor See page 110, #' table 22 in CNAIM (2021). A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param age Numeric. The current age in years of the conductor. #' @param foundation_type String Foundation type of the tower #' @param paint_type String Paint type of the tower #' @param observed_condition_inputs_steelwork Named list observed_conditions_input #' @param observed_condition_inputs_paint Named list observed_conditions_input #' @param observed_condition_inputs_foundation Named list observed_conditions_input #' \code{conductor_samp = c("Low","Medium/Normal","High","Default")}. #' See page 161, table 199 and 201 in CNAIM (2021). #' @inheritParams current_health #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current annual probability of failure for Towers #'pof_towers( #'tower_asset_category = "33kV Tower", #'number_of_operations = "Default", #'placement = "Default", #'altitude_m = "Default", #'distance_from_coast_km = "Default", #'corrosion_category_index = "Default", #'age = 10, #'paint_type = "Paint System - Galvanising", #'foundation_type = "Foundation - Earth Grillage", #'observed_condition_inputs_steelwork = #'list("tower_legs" = list("Condition Criteria: Observed Condition" = "Default"), #'"tower_bracings" = list("Condition Criteria: Observed Condition" = "Default"), #'"tower_crossarms" = list("Condition Criteria: Observed Condition" = "Default"), #'"tower_peak" = list("Condition Criteria: Observed Condition" = "Default")), #'observed_condition_inputs_paint = #'list("paintwork_cond" = list("Condition Criteria: Observed Condition" = "Default")), #'observed_condition_inputs_foundation = #'list("foundation_cond" = list("Condition Criteria: Observed Condition" = "Default")), #'reliability_factor = "Default") pof_towers <- function(tower_asset_category = "33kV Tower", foundation_type = "Foundation - Fully Encased Concrete", paint_type = "Paint System - Paint", placement = "Default", number_of_operations = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, observed_condition_inputs_steelwork, observed_condition_inputs_paint, observed_condition_inputs_foundation, reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Sub-division` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == tower_asset_category) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life ------------------------- normal_expected_life_steelwork <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == tower_asset_category, `Sub-division` == "Steelwork") %>% dplyr::pull() normal_expected_life_foundation <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == tower_asset_category, `Sub-division` == foundation_type) %>% dplyr::pull() normal_expected_life_paint <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == tower_asset_category, `Sub-division` == paint_type) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- # POF function asset category. pof_asset_category <- "Towers" k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` %in% pof_asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ---------------------------------------------------- duty_factor <- 1 # Location factor ---------------------------------------------------- location_factor <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = tower_asset_category) # Expected life for structure ------------------------------ expected_life_years_steelwork <- expected_life(normal_expected_life = normal_expected_life_steelwork, duty_factor, location_factor) # Expected life for paint ------------------------------ expected_life_years_foundation <- expected_life(normal_expected_life = normal_expected_life_foundation, duty_factor, location_factor) # Expected life for paint ------------------------------ expected_life_years_paint <- expected_life(normal_expected_life = normal_expected_life_paint, duty_factor, location_factor) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_steelwork <- beta_1(expected_life_years_steelwork) b1_foundation <- beta_1(expected_life_years_foundation) b1_paint <- beta_1(expected_life_years_paint) # Initial health score ---------------------------------------------------- initial_health_score_steelwork <- initial_health(b1_steelwork, age) initial_health_score_foundation <- initial_health(b1_foundation, age) initial_health_score_paint <- initial_health(b1_paint, age) # Measured conditions measured_condition_modifier <- data.frame(condition_factor = 1, condition_cap = 10, condition_collar = 0.5) # Observed conditions ----------------------------------------------------- # The table data is same for all towers category oci_table_names_steelwork <- list("tower_legs" = "oci_ehv_tower_tower_legs", "tower_bracings" = "oci_ehv_tower_bracings", "tower_crossarms" = "oci_ehv_tower_crossarms", "tower_peak" = "oci_ehv_tower_peak") oci_table_names_paint <- list("paintwork_cond" = "oci_ehv_tower_paintwork_cond") oci_table_names_foundation <- list("foundation_cond" = "oci_ehv_tower_foundation_cond") observed_condition_modifier_steelwork <- get_observed_conditions_modifier_hv_switchgear("EHV Towers", oci_table_names_steelwork, observed_condition_inputs_steelwork, "Tower Steelwork") observed_condition_modifier_paint <- get_observed_conditions_modifier_hv_switchgear("EHV Towers", oci_table_names_paint, observed_condition_inputs_paint, "Tower Paintwork") observed_condition_modifier_foundation <- get_observed_conditions_modifier_hv_switchgear("EHV Towers", oci_table_names_foundation, observed_condition_inputs_foundation, "Foundations") # Health score factor --------------------------------------------------- health_score_factor_steelwork <- health_score_excl_ehv_132kv_tf(observed_condition_modifier_steelwork$condition_factor, measured_condition_modifier$condition_factor) health_score_factor_paint <- health_score_excl_ehv_132kv_tf(observed_condition_modifier_paint$condition_factor, measured_condition_modifier$condition_factor) health_score_factor_foundation <- health_score_excl_ehv_132kv_tf(observed_condition_modifier_foundation$condition_factor, measured_condition_modifier$condition_factor) # Health score cap -------------------------------------------------------- health_score_cap_steelwork <- min(observed_condition_modifier_steelwork$condition_cap, measured_condition_modifier$condition_cap) health_score_cap_paint <- min(observed_condition_modifier_paint$condition_cap, measured_condition_modifier$condition_cap) health_score_cap_foundation <- min(observed_condition_modifier_foundation$condition_cap, measured_condition_modifier$condition_cap) # Health score collar ----------------------------------------------------- health_score_collar_steelowrk <- max(observed_condition_modifier_steelwork$condition_collar, measured_condition_modifier$condition_collar) health_score_collar_paint <- max(observed_condition_modifier_paint$condition_collar, measured_condition_modifier$condition_collar) health_score_collar_foundation <- max(observed_condition_modifier_foundation$condition_collar, measured_condition_modifier$condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier_steelwork <- data.frame(health_score_factor_steelwork, health_score_cap_steelwork, health_score_collar_steelowrk) health_score_modifier_paint <- data.frame(health_score_factor_paint, health_score_cap_paint, health_score_collar_paint) health_score_modifier_foundation <- data.frame(health_score_factor_foundation, health_score_cap_foundation, health_score_collar_foundation) # Current health score ---------------------------------------------------- current_health_score_steelwork <- current_health(initial_health_score_steelwork, health_score_modifier_steelwork$health_score_factor, health_score_modifier_steelwork$health_score_cap, health_score_modifier_steelwork$health_score_collar, reliability_factor = reliability_factor) current_health_score_paint <- current_health(initial_health_score_paint, health_score_modifier_paint$health_score_factor, health_score_modifier_paint$health_score_cap, health_score_modifier_paint$health_score_collar, reliability_factor = reliability_factor) current_health_score_foundation <- current_health(initial_health_score_foundation, health_score_modifier_foundation$health_score_factor, health_score_modifier_foundation$health_score_cap, health_score_modifier_foundation$health_score_collar, reliability_factor = reliability_factor) current_health_score_paint <- min(current_health_score_paint, 6.4) current_health_score <- max(current_health_score_foundation, current_health_score_steelwork, current_health_score_paint) # Probability of failure --------------------------------------------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_towers.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 0.4/10kV Transformers #' @description This function calculates the current #' annual probability of failure for 0.4/10kV Transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @inheritParams location_factor #' @inheritParams current_health #' @param age Numeric. The current age in years. #' @param partial_discharge String. Indicating the #' level of partial discharge. Options for \code{partial_discharge}: #' \code{partial_discharge = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. #' @inheritParams oil_test_modifier #' @param temperature_reading String. Indicating the criticality. #' Options for \code{temperature_reading}: #' \code{temperature_reading = c("Normal", "Moderately High", #' "Very High", "Default")}. #' @param observed_condition String. Indicating the observed condition of the #' transformer. Options for \code{observed_condition}: #' \code{observed_condition = c("No deterioration", "Superficial/minor deterioration", "Slight deterioration", #' "Some Deterioration", "Substantial Deterioration", "Default")}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param moisture Numeric. the amount of moisture given in (ppm) #' @param acidity Numeric. the amount of acidicy given in (mg KOH/g) #' @param bd_strength Numeric. the amount of breakdown strength given in (kV) #' @param utilisation_pct Numeric Utilisation percentage #' @param acidity Oil Acidity #' @param k_value Numeric. \code{k_value = 0.0077} by default. This number is #' given in a percentage. The default value is accordingly to the standard #' "DE-10kV apb kabler CNAIM" on p. 34. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life Numeric. \code{normal_expected_life = 55} by default. #' The default value is accordingly to the standard #' "DE-10kV apb kabler CNAIM" on p. 33. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current probability of failure for 0.4/10kV Transformers #' pof_transformer_04_10kv(utilisation_pct = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' partial_discharge = "Default", #' temperature_reading = "Default", #' observed_condition = "Default", #' reliability_factor = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' k_value = 0.0077, #' c_value = 1.087, #' normal_expected_life = 55) pof_transformer_04_10kv <- function(utilisation_pct = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, partial_discharge = "Default", temperature_reading = "Default", observed_condition = "Default", reliability_factor = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", k_value = 0.0077, c_value = 1.087, normal_expected_life = 55) { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Condition Criteria: Sheath Test Result` = `Condition Criteria: Partial Discharge Test Result` = NULL hv_transformer_type <- "6.6/11kV Transformer (GM)" # this is in order to access tables the are identical to the ones 0.4/10kV transformer is using # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_type <- hv_transformer_type asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- k_value/100 # see page 31 in DE-10kV apb kabler CNAIM c <- c_value # see page 31 in DE-10kV apb kabler CNAIM # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_11_20kv(utilisation_pct) # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type) # Expected life for 0.4/10 kV transformer ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_tf_11kv, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Partial discharge ------------------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_hv_tf_partial_discharge ci_factor_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_cap_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_collar_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_hv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors <- c(ci_factor_partial_discharge, oil_test_mod$oil_condition_factor, ci_factor_temp_reading) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) # Measured condition cap -------------------------------------------------- caps <- c(ci_cap_partial_discharge, oil_test_mod$oil_condition_cap, ci_cap_temp_reading) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_partial_discharge, oil_test_mod$oil_condition_collar, ci_collar_temp_reading) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which(oci_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) oci_hv_tf_tf_ext_cond_df <- gb_ref$oci_hv_tf_tf_ext_cond ci_factor_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Factor`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_cap_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Cap`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_collar_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Collar`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] # Observed condition factor ----------------------------------------------- observed_condition_factor <- mmi(factors = ci_factor_ext_cond, factor_divider_1, factor_divider_2, max_no_combined_factors) # Observed condition cap --------------------------------------------- observed_condition_cap <- ci_cap_ext_cond # Observed condition collar --------------------------------------------- observed_condition_collar <- ci_collar_ext_cond # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11kV and 20kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_transformer_04_10kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 6.6/11kV and 20kV Transformers #' @description This function calculates the current #' annual probability of failure for 6.6/11kV and 20kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param hv_transformer_type String. Refers to the high voltage transformer #' type the calculation is done for. Options: \code{hv_transformer_type = #' c("6.6/11kV Transformer (GM)", "20kV Transformer (GM)")}. The default setting #' is \code{hv_transformer_type = 6.6/11kV Transformer (GM)}. #' @inheritParams duty_factor_transformer_11_20kv #' @inheritParams location_factor #' @inheritParams current_health #' @param age Numeric. The current age in years. #' @param partial_discharge String. Indicating the #' @param oil_acidity Oil Acidity #' level of partial discharge. Options for \code{partial_discharge}: #' \code{partial_discharge = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. See page 153, table 171 in CNAIM (2021). #' @inheritParams oil_test_modifier #' See page 162, table 204 in CNAIM (2021). #' @param temperature_reading String. Indicating the criticality. #' Options for \code{temperature_reading}: #' \code{temperature_reading = c("Normal", "Moderately High", #' "Very High", "Default")}. See page 153, table 172 in CNAIM (2021). #' @param observed_condition String. Indicating the observed condition of the #' transformer. Options for \code{observed_condition}: #' \code{observed_condition = c("No deterioration", "Superficial/minor deterioration", "Slight deterioration", #' "Some Deterioration", "Substantial Deterioration", "Default")}. See page 130, table 81 in CNAIM (2021). #' @param moisture Numeric. the amount of moisture given in (ppm) See page 162, table 203 in CNAIM (2021). #' @param bd_strength Numeric. the amount of breakdown strength given in (kV) See page 162, table 205 in CNAIM (2021). #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current probability of failure for a 6.6/11 kV transformer #' pof_transformer_11_20kv(hv_transformer_type = "6.6/11kV Transformer (GM)", #' utilisation_pct = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age = 10, #' partial_discharge = "Default", #' temperature_reading = "Default", #' observed_condition = "Default", #' reliability_factor = "Default", #' moisture = "Default", #' oil_acidity = "Default", #' bd_strength = "Default") pof_transformer_11_20kv <- function(hv_transformer_type = "6.6/11kV Transformer (GM)", utilisation_pct = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age, partial_discharge = "Default", temperature_reading = "Default", observed_condition = "Default", reliability_factor = "Default", moisture = "Default", oil_acidity = "Default", bd_strength = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_type <- hv_transformer_type asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for 6.6/11 kV transformer ------------------------------ normal_expected_life <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == asset_category) %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_11_20kv(utilisation_pct) # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type) # Expected life for6.6/11 kV transformer ------------------------------ expected_life_years <- expected_life(normal_expected_life, duty_factor_tf_11kv, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1 <- beta_1(expected_life_years) # Initial health score ---------------------------------------------------- initial_health_score <- initial_health(b1, age) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(mcm_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) # Partial discharge ------------------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_hv_tf_partial_discharge ci_factor_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_cap_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] ci_collar_partial_discharge <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge)] # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, oil_acidity, bd_strength) # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_hv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors <- c(ci_factor_partial_discharge, oil_test_mod$oil_condition_factor, ci_factor_temp_reading) measured_condition_factor <- mmi(factors, factor_divider_1, factor_divider_2, max_no_combined_factors) # Measured condition cap -------------------------------------------------- caps <- c(ci_cap_partial_discharge, oil_test_mod$oil_condition_cap, ci_cap_temp_reading) measured_condition_cap <- min(caps) # Measured condition collar ----------------------------------------------- collars <- c(ci_collar_partial_discharge, oil_test_mod$oil_condition_collar, ci_collar_temp_reading) measured_condition_collar <- max(collars) # Measured condition modifier --------------------------------------------- measured_condition_modifier <- data.frame(measured_condition_factor, measured_condition_cap, measured_condition_collar) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal oci_mmi_cal_df <- oci_mmi_cal_df[which(oci_mmi_cal_df$`Asset Category` == asset_category), ] factor_divider_1 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 1`) factor_divider_2 <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Factor Divider 2`) max_no_combined_factors <- as.numeric(oci_mmi_cal_df$ `Parameters for Combination Using MMI Technique - Max. No. of Combined Factors` ) oci_hv_tf_tf_ext_cond_df <- gb_ref$oci_hv_tf_tf_ext_cond ci_factor_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Factor`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_cap_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Cap`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] ci_collar_ext_cond <- oci_hv_tf_tf_ext_cond_df$`Condition Input Collar`[which( oci_hv_tf_tf_ext_cond_df$`Condition Criteria: Observed Condition` == observed_condition)] # Observed condition factor ----------------------------------------------- observed_condition_factor <- mmi(factors = ci_factor_ext_cond, factor_divider_1, factor_divider_2, max_no_combined_factors) # Observed condition cap --------------------------------------------- observed_condition_cap <- ci_cap_ext_cond # Observed condition collar --------------------------------------------- observed_condition_collar <- ci_collar_ext_cond # Observed condition modifier --------------------------------------------- observed_condition_modifier <- data.frame(observed_condition_factor, observed_condition_cap, observed_condition_collar) # Health score factor --------------------------------------------------- health_score_factor <- health_score_excl_ehv_132kv_tf(observed_condition_factor, measured_condition_factor) # Health score cap -------------------------------------------------------- health_score_cap <- min(observed_condition_cap, measured_condition_cap) # Health score collar ----------------------------------------------------- health_score_collar <- max(observed_condition_collar, measured_condition_collar) # Health score modifier --------------------------------------------------- health_score_modifier <- data.frame(health_score_factor, health_score_cap, health_score_collar) # Current health score ---------------------------------------------------- current_health_score <- current_health(initial_health_score, health_score_modifier$health_score_factor, health_score_modifier$health_score_cap, health_score_modifier$health_score_collar, reliability_factor = reliability_factor) # Probability of failure for the 6.6/11kV and 20kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_transformer_11_20kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 132kv Transformers #' @description This function calculates the current #' annual probability of failure for 132kv transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param transformer_type String. A sting that refers to the specific #' asset category. See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{transformer_type = #' c("132kV Transformer (GM)"} #' @param year_of_manufacture Numeric. Normal expected life depends on the #' year for manufacture, see page 107 table 20 in CNAIM (2021). #' @inheritParams duty_factor_transformer_33_66kv #' @inheritParams location_factor #' @inheritParams current_health #' @param age_tf Numeric. The current age in years #' of the transformer. #' @param age_tc Numeric. The current age in years #' of the tapchanger #' @param partial_discharge_tf String. Indicating the #' level of partial discharge in the transformer. #' Options: #' \code{partial_discharge_tf = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. See page 155, table 176 in CNAIM (2021). #' @param partial_discharge_tc String. Indicating the #' level of partial discharge in the tapchanger #' Options: #' \code{partial_discharge_tc = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. See page 156, table 178 in CNAIM (2021). #' @param temperature_reading String. Indicating the criticality. #' Options: #' \code{temperature_reading = c("Normal", "Moderately High", #' "Very High", "Default")}. See page 155, table 177 in CNAIM (2021). #' @param main_tank String. Indicating the observed condition of the #' main tank. Options: #' \code{main_tank = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 134, table 93 #' in CNAIM (2021). #' @param coolers_radiator String. Indicating the observed condition of the #' coolers/radiators. Options: #' \code{coolers_radiator = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 134, table 94 #' in CNAIM (2021). #' @param bushings String. Indicating the observed condition of the #' bushings. Options: #' \code{bushings = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 135, table 95 #' in CNAIM (2021). #' @param kiosk String. Indicating the observed condition of the #' kiosk. Options: #' \code{kiosk = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 135, table 96 #' in CNAIM (2021). #' @param cable_boxes String. Indicating the observed condition of the #' cable boxes. Options: #' \code{cable_boxes = c("No Deterioration","Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 135, table 97 #' in CNAIM (2021). #' @param external_tap String. Indicating the observed external condition of the #' tapchanger. Options: #' \code{external_tap = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 136, table 98 #' in CNAIM (2021). #' @param internal_tap String. Indicating the observed internal condition of the #' tapchanger. Options: #' \code{internal_tap = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 136, table 99 #' in CNAIM (2021). #' @param mechnism_cond String. Indicating the observed condition of the #' drive mechnism. Options: #' \code{mechnism_cond = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 136, table 100 #' in CNAIM (2021). #' @param diverter_contacts String. Indicating the observed condition of the #' selector and diverter contacts. Options: #' \code{diverter_contacts = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 136, table 101 #' in CNAIM (2021). #' @param diverter_braids String. Indicating the observed condition of the #' selector and diverter braids. Options: #' \code{diverter_braids = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 136, table 102 #' in CNAIM (2021) #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param moisture Numeric. the amount of moisture given in (ppm) See page 162, table 203 in CNAIM (2021). #' @param acidity Numeric. the amount of acidicy given in (mg KOH/g) See page 162, table 204 in CNAIM (2021). #' @param bd_strength Numeric. the amount of breakdown strength given in (kV) See page 162, table 205 in CNAIM (2021). #' @inheritParams oil_test_modifier #' @inheritParams dga_test_modifier #' @inheritParams ffa_test_modifier #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current probability of failure for a 132kV transformer #' pof_transformer_132kv(transformer_type = "132kV Transformer (GM)", #' year_of_manufacture = 1980, #' utilisation_pct = "Default", #' no_taps = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age_tf = 43, #' age_tc = 43, #' partial_discharge_tf = "Default", #' partial_discharge_tc = "Default", #' temperature_reading = "Default", #' main_tank = "Default", #' coolers_radiator = "Default", #' bushings = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' external_tap = "Default", #' internal_tap = "Default", #' mechnism_cond = "Default", #' diverter_contacts = "Default", #' diverter_braids = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' hydrogen = "Default", #' methane = "Default", #' ethylene = "Default", #' ethane = "Default", #' acetylene = "Default", #' hydrogen_pre = "Default", #' methane_pre = "Default", #' ethylene_pre = "Default", #' ethane_pre = "Default", #' acetylene_pre = "Default", #' furfuraldehyde = "Default", #' reliability_factor = "Default") pof_transformer_132kv <- function(transformer_type = "132kV Transformer (GM)", year_of_manufacture, utilisation_pct = "Default", no_taps = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age_tf, age_tc, partial_discharge_tf = "Default", partial_discharge_tc = "Default", temperature_reading = "Default", main_tank = "Default", coolers_radiator = "Default", bushings = "Default", kiosk = "Default", cable_boxes = "Default", external_tap = "Default", internal_tap = "Default", mechnism_cond = "Default", diverter_contacts = "Default", diverter_braids = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", hydrogen = "Default", methane = "Default", ethylene = "Default", ethane = "Default", acetylene = "Default", hydrogen_pre = "Default", methane_pre = "Default", ethylene_pre = "Default", ethane_pre = "Default", acetylene_pre = "Default", furfuraldehyde = "Default", reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for transformer ----------------------------- if (year_of_manufacture < 1980) { sub_division <- "Transformer - Pre 1980" } else { sub_division <- "Transformer - Post 1980" } normal_expected_life_tf <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == sub_division) %>% dplyr::pull() # Normal expected life for tapchanger ----------------------------- normal_expected_life_tc <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == "Tapchanger") %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_33_66kv(utilisation_pct, no_taps) duty_factor_tf <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "transformer")] duty_factor_tc <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "tapchanger")] # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for transformer ------------------------------ expected_life_years_tf <- expected_life(normal_expected_life = normal_expected_life_tf, duty_factor_tf, location_factor_transformer) # Expected life for tapchanger ------------------------------ expected_life_years_tc <- expected_life(normal_expected_life = normal_expected_life_tc, duty_factor_tc, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_tf <- beta_1(expected_life_years_tf) b1_tc <- beta_1(expected_life_years_tc) # Initial health score ---------------------------------------------------- initial_health_score_tf <- initial_health(b1_tf, age_tf) initial_health_score_tc <- initial_health(b1_tc, age_tc) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "132kV Transformer (GM)"), ] factor_divider_1_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Partial discharge transformer ---------------------------------------------- mci_132kv_tf_partial_discharge <- gb_ref$mci_132kv_tf_main_tf_prtl_dis ci_factor_partial_discharge_tf <- mci_132kv_tf_partial_discharge$`Condition Input Factor`[which( mci_132kv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_cap_partial_discharge_tf <- mci_132kv_tf_partial_discharge$`Condition Input Cap`[which( mci_132kv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_collar_partial_discharge_tf <- mci_132kv_tf_partial_discharge$`Condition Input Collar`[which( mci_132kv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] # Partial discharge tapchanger ------------------------------------------------ mci_132kv_tf_partial_discharge_tc <- gb_ref$mci_132kv_tf_tpchngr_prtl_dis ci_factor_partial_discharge_tc <- mci_132kv_tf_partial_discharge_tc$`Condition Input Factor`[which( mci_132kv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_cap_partial_discharge_tc <- mci_132kv_tf_partial_discharge_tc$`Condition Input Cap`[which( mci_132kv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_collar_partial_discharge_tc <- mci_132kv_tf_partial_discharge_tc$`Condition Input Collar`[which( mci_132kv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] # Temperature readings ---------------------------------------------------- mci_132kv_tf_temp_readings <- gb_ref$mci_132kv_tf_temp_readings ci_factor_temp_reading <- mci_132kv_tf_temp_readings$`Condition Input Factor`[which( mci_132kv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_132kv_tf_temp_readings$`Condition Input Cap`[which( mci_132kv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_132kv_tf_temp_readings$`Condition Input Collar`[which( mci_132kv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors_tf <- c(ci_factor_partial_discharge_tf, ci_factor_temp_reading) measured_condition_factor_tf <- mmi(factors_tf, factor_divider_1_tf, factor_divider_2_tf, max_no_combined_factors_tf) measured_condition_factor_tc <- mmi(ci_factor_partial_discharge_tc, factor_divider_1_tc, factor_divider_2_tc, max_no_combined_factors_tc) # Measured condition cap -------------------------------------------------- caps_tf <- c(ci_cap_partial_discharge_tf, ci_cap_temp_reading) measured_condition_cap_tf <- min(caps_tf) measured_condition_cap_tc <- ci_cap_partial_discharge_tc # Measured condition collar ----------------------------------------------- collars_tf <- c(ci_collar_partial_discharge_tf, ci_collar_temp_reading) measured_condition_collar_tf <- max(collars_tf) measured_condition_collar_tc <- ci_collar_partial_discharge_tc # Measured condition modifier --------------------------------------------- measured_condition_modifier_tf <- data.frame(measured_condition_factor_tf, measured_condition_cap_tf, measured_condition_collar_tf) measured_condition_modifier_tc <- data.frame(measured_condition_factor_tc, measured_condition_cap_tc, measured_condition_collar_tc) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "132kV Transformer (GM)") factor_divider_1_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Transformer ------------------------------------------------------------- # Main tank condition oci_132kv_tf_main_tank_cond <- gb_ref$oci_132kv_tf_main_tank_cond Oi_collar_main_tank <- oci_132kv_tf_main_tank_cond$`Condition Input Collar`[which( oci_132kv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_cap_main_tank <- oci_132kv_tf_main_tank_cond$`Condition Input Cap`[which( oci_132kv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_factor_main_tank <- oci_132kv_tf_main_tank_cond$`Condition Input Factor`[which( oci_132kv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] # Coolers/Radiator condition oci_132kv_tf_cooler_radiatr_cond <- gb_ref$oci_132kv_tf_cooler_radtr_cond Oi_collar_coolers_radiator <- oci_132kv_tf_cooler_radiatr_cond$`Condition Input Collar`[which( oci_132kv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_132kv_tf_cooler_radiatr_cond$`Condition Input Cap`[which( oci_132kv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_132kv_tf_cooler_radiatr_cond$`Condition Input Factor`[which( oci_132kv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Bushings oci_132kv_tf_bushings_cond <- gb_ref$oci_132kv_tf_bushings_cond Oi_collar_bushings <- oci_132kv_tf_bushings_cond$`Condition Input Collar`[which( oci_132kv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_cap_bushings <- oci_132kv_tf_bushings_cond$`Condition Input Cap`[which( oci_132kv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_factor_bushings <- oci_132kv_tf_bushings_cond$`Condition Input Factor`[which( oci_132kv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] # Kiosk oci_132kv_tf_kiosk_cond <- gb_ref$oci_132kv_tf_kiosk_cond Oi_collar_kiosk <- oci_132kv_tf_kiosk_cond$`Condition Input Collar`[which( oci_132kv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_132kv_tf_kiosk_cond$`Condition Input Cap`[which( oci_132kv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_132kv_tf_kiosk_cond$`Condition Input Factor`[which( oci_132kv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_132kv_tf_cable_boxes_cond <- gb_ref$oci_132kv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_132kv_tf_cable_boxes_cond$`Condition Input Collar`[which( oci_132kv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_132kv_tf_cable_boxes_cond$`Condition Input Cap`[which( oci_132kv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_132kv_tf_cable_boxes_cond$`Condition Input Factor`[which( oci_132kv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Tapchanger -------------------------------------------------------------- # External condition oci_132kv_tf_tapchanger_ext_cond <- gb_ref$oci_132kv_tf_tapchngr_ext_cond Oi_collar_external_tap <- oci_132kv_tf_tapchanger_ext_cond$`Condition Input Collar`[which( oci_132kv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_cap_external_tap <- oci_132kv_tf_tapchanger_ext_cond$`Condition Input Cap`[which( oci_132kv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_factor_external_tap <- oci_132kv_tf_tapchanger_ext_cond$`Condition Input Factor`[which( oci_132kv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] # Internal condition oci_132kv_tf_int_cond <- gb_ref$oci_132kv_tf_int_cond Oi_collar_internal_tap <- oci_132kv_tf_int_cond$`Condition Input Collar`[which( oci_132kv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_cap_internal_tap <- oci_132kv_tf_int_cond$`Condition Input Cap`[which( oci_132kv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_factor_internal_tap <- oci_132kv_tf_int_cond$`Condition Input Factor`[which( oci_132kv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] # Drive mechanism oci_132kv_tf_drive_mechnism_cond <- gb_ref$oci_132kv_tf_drive_mechsm_cond Oi_collar_mechnism_cond <- oci_132kv_tf_drive_mechnism_cond$`Condition Input Collar`[which( oci_132kv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_cap_mechnism_cond <- oci_132kv_tf_drive_mechnism_cond$`Condition Input Cap`[which( oci_132kv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_factor_mechnism_cond <- oci_132kv_tf_drive_mechnism_cond$`Condition Input Factor`[which( oci_132kv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] # Selecter diverter contacts oci_132kv_tf_cond_select_divrter_cst <- gb_ref$oci_132kv_tf_cond_select_div_c Oi_collar_diverter_contacts <- oci_132kv_tf_cond_select_divrter_cst$`Condition Input Collar`[which( oci_132kv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_cap_diverter_contacts <- oci_132kv_tf_cond_select_divrter_cst$`Condition Input Cap`[which( oci_132kv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_factor_diverter_contacts <- oci_132kv_tf_cond_select_divrter_cst$`Condition Input Factor`[which( oci_132kv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] # Selecter diverter braids oci_132kv_tf_cond_select_divrter_brd <- gb_ref$oci_132kv_tf_cond_select_div_b Oi_collar_diverter_braids <- oci_132kv_tf_cond_select_divrter_brd$`Condition Input Collar`[which( oci_132kv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_cap_diverter_braids <- oci_132kv_tf_cond_select_divrter_brd$`Condition Input Cap`[which( oci_132kv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_factor_diverter_braids <- oci_132kv_tf_cond_select_divrter_brd$`Condition Input Factor`[which( oci_132kv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] # Observed condition factor -------------------------------------- # Transformer factors_tf_obs <- c(Oi_factor_main_tank, Oi_factor_coolers_radiator, Oi_factor_bushings, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor_tf <- mmi(factors_tf_obs, factor_divider_1_tf_obs, factor_divider_2_tf_obs, max_no_combined_factors_tf_obs) # Tapchanger factors_tc_obs <- c(Oi_factor_external_tap, Oi_factor_internal_tap, Oi_factor_mechnism_cond, Oi_factor_diverter_contacts, Oi_factor_diverter_braids) observed_condition_factor_tc <- mmi(factors_tc_obs, factor_divider_1_tc_obs, factor_divider_2_tc_obs, max_no_combined_factors_tc_obs) # Observed condition cap ----------------------------------------- # Transformer caps_tf_obs <- c(Oi_cap_main_tank, Oi_cap_coolers_radiator, Oi_cap_bushings, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap_tf <- min(caps_tf_obs) # Tapchanger caps_tc_obs <- c(Oi_cap_external_tap, Oi_cap_internal_tap, Oi_cap_mechnism_cond, Oi_cap_diverter_contacts, Oi_cap_diverter_braids) observed_condition_cap_tc <- min(caps_tc_obs) # Observed condition collar --------------------------------------- # Transformer collars_tf_obs <- c(Oi_collar_main_tank, Oi_collar_coolers_radiator, Oi_collar_bushings, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar_tf <- max(collars_tf_obs) # Tapchanger collars_tc_obs <- c(Oi_collar_external_tap, Oi_collar_internal_tap, Oi_collar_mechnism_cond, Oi_collar_diverter_contacts, Oi_collar_diverter_braids) observed_condition_collar_tc <- max(collars_tc_obs) # Observed condition modifier --------------------------------------------- # Transformer observed_condition_modifier_tf <- data.frame(observed_condition_factor_tf, observed_condition_cap_tf, observed_condition_collar_tf) # Tapchanger observed_condition_modifier_tc <- data.frame(observed_condition_factor_tc, observed_condition_cap_tc, observed_condition_collar_tc) # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # DGA test modifier ------------------------------------------------------- dga_test_mod <- dga_test_modifier(hydrogen, methane, ethylene, ethane, acetylene, hydrogen_pre, methane_pre, ethylene_pre, ethane_pre, acetylene_pre) # FFA test modifier ------------------------------------------------------- ffa_test_mod <- ffa_test_modifier(furfuraldehyde) # Health score factor --------------------------------------------------- health_score_factor_for_tf <- gb_ref$health_score_factor_for_tf health_score_factor_tapchanger <- gb_ref$health_score_factor_tapchanger # Transformer factor_divider_1_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Tapchanger factor_divider_1_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- # Transformer obs_tf_factor <- observed_condition_modifier_tf$observed_condition_factor_tf mea_tf_factor <- measured_condition_modifier_tf$measured_condition_factor_tf oil_factor <- oil_test_mod$oil_condition_factor dga_factor <- dga_test_mod$dga_test_factor ffa_factor <- ffa_test_mod$ffa_test_factor factors_tf_health <- c(obs_tf_factor, mea_tf_factor, oil_factor, dga_factor, ffa_factor) health_score_factor_tf <- mmi(factors_tf_health, factor_divider_1_tf_health, factor_divider_2_tf_health, max_no_combined_factors_tf_health) # tapchanger obs_tc_factor <- observed_condition_modifier_tc$observed_condition_factor_tc mea_tc_factor <- measured_condition_modifier_tc$measured_condition_factor_tc factors_tc_health <- c(obs_tc_factor, mea_tc_factor, oil_factor) health_score_factor_tc <- mmi(factors_tc_health, factor_divider_1_tc_health, factor_divider_2_tc_health, max_no_combined_factors_tc_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap_tf <- min(observed_condition_modifier_tf$observed_condition_cap_tf, measured_condition_modifier_tf$measured_condition_cap_tf, oil_test_mod$oil_condition_cap, dga_test_mod$dga_test_cap, ffa_test_mod$ffa_test_cap) # Tapchanger health_score_cap_tc <- min(observed_condition_modifier_tc$observed_condition_cap_tc, measured_condition_modifier_tc$measured_condition_cap_tc, oil_test_mod$oil_condition_cap) # Health score collar ----------------------------------------------------- # Transformer health_score_collar_tf <- max(observed_condition_modifier_tf$observed_condition_collar_tf, measured_condition_modifier_tf$measured_condition_collar_tf, oil_test_mod$oil_condition_collar, dga_test_mod$dga_test_collar, ffa_test_mod$ffa_test_collar) # Tapchanger health_score_collar_tc <- max(observed_condition_modifier_tc$observed_condition_collar_tc, measured_condition_modifier_tc$measured_condition_collar_tc, oil_test_mod$oil_condition_collar) # Health score modifier --------------------------------------------------- # transformer health_score_modifier_tf <- data.frame(health_score_factor_tf, health_score_cap_tf, health_score_collar_tf) # Tapchanger health_score_modifier_tc <- data.frame(health_score_factor_tc, health_score_cap_tc, health_score_collar_tc) # Current health score ---------------------------------------------------- # Transformer current_health_score <- max(current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor), current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor)) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_transformer_132kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 30/10kV and 60/10kV Transformers #' @description This function calculates the current #' annual probability of failure for 30/10kV and 60/10kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. #' @param placement String. Specify if the asset is located outdoor or indoor. #' @param altitude_m Numeric. Specify the altitude location for #' the asset measured in meters from sea level.\code{altitude_m} #' is used to derive the altitude factor. A setting of \code{"Default"} #' will set the altitude factor to 1 independent of \code{asset_type}. #' @param distance_from_coast_km Numeric. Specify the distance from the #' coast measured in kilometers. \code{distance_from_coast_km} is used #' to derive the distance from coast factor. A setting of \code{"Default"} will set the #' distance from coast factor to 1 independent of \code{asset_type}. #' @param transformer_type String. A sting that refers to the specific #' asset category. #' Options: #' \code{transformer_type = #' c("30kV Transformer (GM)", "60kV Transformer (GM)")}. The default setting is #' \code{transformer_type = "60kV Transformer (GM)"} #' @param year_of_manufacture Numeric. Normal expected life depends on the #' year for manufacture. #' @inheritParams duty_factor_transformer_33_66kv #' @inheritParams location_factor #' @inheritParams current_health #' @param age_tf Numeric. The current age in years #' of the transformer. #' @param age_tc Numeric. The current age in years #' of the tapchanger #' @param partial_discharge_tf String. Indicating the #' level of partial discharge in the transformer. #' Options: #' \code{partial_discharge_tf = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. #' @param partial_discharge_tc String. Indicating the #' level of partial discharge in the tapchanger #' Options: #' \code{partial_discharge_tc = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. #' @param temperature_reading String. Indicating the criticality. #' Options: #' \code{temperature_reading = c("Normal", "Moderately High", #' "Very High", "Default")}. #' @param main_tank String. Indicating the observed condition of the #' main tank. Options: #' \code{main_tank = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param coolers_radiator String. Indicating the observed condition of the #' coolers/radiators. Options: #' \code{coolers_radiator = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param bushings String. Indicating the observed condition of the #' bushings. Options: #' \code{bushings = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' @param kiosk String. Indicating the observed condition of the #' kiosk. Options: #' \code{kiosk = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' @param cable_boxes String. Indicating the observed condition of the #' cable boxes. Options: #' \code{cable_boxes = c("No Deterioration","Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' @param external_tap String. Indicating the observed external condition of the #' tapchanger. Options: #' \code{external_tap = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param internal_tap String. Indicating the observed internal condition of the #' tapchanger. Options: #' \code{external_tap = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param mechnism_cond String. Indicating the observed condition of the #' drive mechnism. Options: #' \code{mechnism_cond = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param diverter_contacts String. Indicating the observed condition of the #' selector and diverter contacts. Options: #' \code{diverter_contacts = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' in CNAIM (2021). #' @param diverter_braids String. Indicating the observed condition of the #' selector and diverter braids. Options: #' \code{diverter_braids = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param moisture Numeric. the amount of moisture given in (ppm) See page 162, table 203 in CNAIM (2021). #' @param acidity Numeric. the amount of acidicy given in (mg KOH/g) See page 162, table 204 in CNAIM (2021). #' @param bd_strength Numeric. the amount of breakdown strength given in (kV) See page 162, table 205 in CNAIM (2021). #' @param k_value Numeric. \code{k_value = "0.0454"} by default. This number is #' given in a percentage. The default value is accordingly to the CNAIM standard #' on p. 110. #' @param c_value Numeric. \code{c_value = 1.087} by default. #' The default value is accordingly to the CNAIM standard see page 110 #' @param normal_expected_life_tf Numeric. \code{normal_expected_life_tf = "Default"} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @param normal_expected_life_tc Numeric. \code{normal_expected_life_tc = "Default"} by default. #' The default value is accordingly to the CNAIM standard on page 107. #' @inheritParams oil_test_modifier #' @inheritParams dga_test_modifier #' @inheritParams ffa_test_modifier #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @export #' @examples #' # Current probability of failure for a 60/10kV transformer #' pof_transformer_30_60kv(transformer_type = "60kV Transformer (GM)", #' year_of_manufacture = 1980, #' utilisation_pct = "Default", #' no_taps = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age_tf = 43, #' age_tc = 43, #' partial_discharge_tf = "Default", #' partial_discharge_tc = "Default", #' temperature_reading = "Default", #' main_tank = "Default", #' coolers_radiator = "Default", #' bushings = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' external_tap = "Default", #' internal_tap = "Default", #' mechnism_cond = "Default", #' diverter_contacts = "Default", #' diverter_braids = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' hydrogen = "Default", #' methane = "Default", #' ethylene = "Default", #' ethane = "Default", #' acetylene = "Default", #' hydrogen_pre = "Default", #' methane_pre = "Default", #' ethylene_pre = "Default", #' ethane_pre = "Default", #' acetylene_pre = "Default", #' furfuraldehyde = "Default", #' reliability_factor = "Default", #' k_value = 0.454, #' c_value = 1.087, #' normal_expected_life_tf = "Default", #' normal_expected_life_tc = "Default") pof_transformer_30_60kv <- function(transformer_type = "60kV Transformer (GM)", year_of_manufacture, utilisation_pct = "Default", no_taps = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age_tf, age_tc, partial_discharge_tf = "Default", partial_discharge_tc = "Default", temperature_reading = "Default", main_tank = "Default", coolers_radiator = "Default", bushings = "Default", kiosk = "Default", cable_boxes = "Default", external_tap = "Default", internal_tap = "Default", mechnism_cond = "Default", diverter_contacts = "Default", diverter_braids = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", hydrogen = "Default", methane = "Default", ethylene = "Default", ethane = "Default", acetylene = "Default", hydrogen_pre = "Default", methane_pre = "Default", ethylene_pre = "Default", ethane_pre = "Default", acetylene_pre = "Default", furfuraldehyde = "Default", reliability_factor = "Default", k_value = 0.454, c_value = 1.087, normal_expected_life_tf = "Default", normal_expected_life_tc = "Default") { if (transformer_type == "30kV Transformer (GM)" ) { transformer_type <- "33kV Transformer (GM)" } else { transformer_type <- "66kV Transformer (GM)" } `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for transformer ----------------------------- if (year_of_manufacture < 1980) { sub_division <- "Transformer - Pre 1980" } else { sub_division <- "Transformer - Post 1980" } if (normal_expected_life_tf == "Default") { normal_expected_life_tf <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == sub_division) %>% dplyr::pull() } else { normal_expected_life_tf <- normal_expected_life_tf } # Normal expected life for tapchanger ----------------------------- if (normal_expected_life_tc == "Default") { normal_expected_life_tc <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == "Tapchanger") %>% dplyr::pull() } else { normal_expected_life_tc <- normal_expected_life_tc } # Constants C and K for PoF function -------------------------------------- k <- k_value/100 c <- c_value # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_33_66kv(utilisation_pct, no_taps) duty_factor_tf <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "transformer")] duty_factor_tc <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "tapchanger")] # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for transformer ------------------------------ expected_life_years_tf <- expected_life(normal_expected_life = normal_expected_life_tf, duty_factor_tf, location_factor_transformer) # Expected life for tapchanger ------------------------------ expected_life_years_tc <- expected_life(normal_expected_life = normal_expected_life_tc, duty_factor_tc, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_tf <- beta_1(expected_life_years_tf) b1_tc <- beta_1(expected_life_years_tc) # Initial health score ---------------------------------------------------- initial_health_score_tf <- initial_health(b1_tf, age_tf) initial_health_score_tc <- initial_health(b1_tc, age_tc) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "EHV Transformer (GM)"), ] factor_divider_1_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Partial discharge transformer ---------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_ehv_tf_main_tf_prtl_dis ci_factor_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_cap_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_collar_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] # Partial discharge tapchanger ------------------------------------------------ mci_hv_tf_partial_discharge_tc <- gb_ref$mci_ehv_tf_tapchngr_prtl_dis ci_factor_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Factor`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_cap_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Cap`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_collar_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Collar`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_ehv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors_tf <- c(ci_factor_partial_discharge_tf, ci_factor_temp_reading) measured_condition_factor_tf <- mmi(factors_tf, factor_divider_1_tf, factor_divider_2_tf, max_no_combined_factors_tf) measured_condition_factor_tc <- mmi(ci_factor_partial_discharge_tc, factor_divider_1_tc, factor_divider_2_tc, max_no_combined_factors_tc) # Measured condition cap -------------------------------------------------- caps_tf <- c(ci_cap_partial_discharge_tf, ci_cap_temp_reading) measured_condition_cap_tf <- min(caps_tf) measured_condition_cap_tc <- ci_cap_partial_discharge_tc # Measured condition collar ----------------------------------------------- collars_tf <- c(ci_collar_partial_discharge_tf, ci_collar_temp_reading) measured_condition_collar_tf <- max(collars_tf) measured_condition_collar_tc <- ci_collar_partial_discharge_tc # Measured condition modifier --------------------------------------------- measured_condition_modifier_tf <- data.frame(measured_condition_factor_tf, measured_condition_cap_tf, measured_condition_collar_tf) measured_condition_modifier_tc <- data.frame(measured_condition_factor_tc, measured_condition_cap_tc, measured_condition_collar_tc) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "EHV Transformer (GM)") factor_divider_1_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Transformer ------------------------------------------------------------- # Main tank condition oci_ehv_tf_main_tank_cond <- gb_ref$oci_ehv_tf_main_tank_cond Oi_collar_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Collar`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_cap_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Cap`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_factor_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Factor`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] # Coolers/Radiator condition oci_ehv_tf_cooler_radiatr_cond <- gb_ref$oci_ehv_tf_cooler_radiatr_cond Oi_collar_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Collar`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Cap`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Factor`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Bushings oci_ehv_tf_bushings_cond <- gb_ref$oci_ehv_tf_bushings_cond Oi_collar_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Collar`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_cap_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Cap`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_factor_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Factor`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] # Kiosk oci_ehv_tf_kiosk_cond <- gb_ref$oci_ehv_tf_kiosk_cond Oi_collar_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Collar`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Cap`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Factor`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_ehv_tf_cable_boxes_cond <- gb_ref$oci_ehv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Collar`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Cap`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Factor`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Tapchanger -------------------------------------------------------------- # External condition oci_ehv_tf_tapchanger_ext_cond <- gb_ref$oci_ehv_tf_tapchanger_ext_cond Oi_collar_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Collar`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_cap_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Cap`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_factor_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Factor`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] # Internal condition oci_ehv_tf_int_cond <- gb_ref$oci_ehv_tf_int_cond Oi_collar_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Collar`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_cap_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Cap`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_factor_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Factor`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] # Drive mechanism oci_ehv_tf_drive_mechnism_cond <- gb_ref$oci_ehv_tf_drive_mechnism_cond Oi_collar_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Collar`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_cap_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Cap`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_factor_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Factor`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] # Selecter diverter contacts oci_ehv_tf_cond_select_divrter_cst <- gb_ref$oci_ehv_tf_cond_select_div_cts Oi_collar_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_cap_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_factor_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] # Selecter diverter braids oci_ehv_tf_cond_select_divrter_brd <- gb_ref$oci_ehv_tf_cond_select_div_brd Oi_collar_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_cap_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_factor_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] # Observed condition factor -------------------------------------- # Transformer factors_tf_obs <- c(Oi_factor_main_tank, Oi_factor_coolers_radiator, Oi_factor_bushings, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor_tf <- mmi(factors_tf_obs, factor_divider_1_tf_obs, factor_divider_2_tf_obs, max_no_combined_factors_tf_obs) # Tapchanger factors_tc_obs <- c(Oi_factor_external_tap, Oi_factor_internal_tap, Oi_factor_mechnism_cond, Oi_factor_diverter_contacts, Oi_factor_diverter_braids) observed_condition_factor_tc <- mmi(factors_tc_obs, factor_divider_1_tc_obs, factor_divider_2_tc_obs, max_no_combined_factors_tc_obs) # Observed condition cap ----------------------------------------- # Transformer caps_tf_obs <- c(Oi_cap_main_tank, Oi_cap_coolers_radiator, Oi_cap_bushings, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap_tf <- min(caps_tf_obs) # Tapchanger caps_tc_obs <- c(Oi_cap_external_tap, Oi_cap_internal_tap, Oi_cap_mechnism_cond, Oi_cap_diverter_contacts, Oi_cap_diverter_braids) observed_condition_cap_tc <- min(caps_tc_obs) # Observed condition collar --------------------------------------- # Transformer collars_tf_obs <- c(Oi_collar_main_tank, Oi_collar_coolers_radiator, Oi_collar_bushings, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar_tf <- max(collars_tf_obs) # Tapchanger collars_tc_obs <- c(Oi_collar_external_tap, Oi_collar_internal_tap, Oi_collar_mechnism_cond, Oi_collar_diverter_contacts, Oi_collar_diverter_braids) observed_condition_collar_tc <- max(collars_tc_obs) # Observed condition modifier --------------------------------------------- # Transformer observed_condition_modifier_tf <- data.frame(observed_condition_factor_tf, observed_condition_cap_tf, observed_condition_collar_tf) # Tapchanger observed_condition_modifier_tc <- data.frame(observed_condition_factor_tc, observed_condition_cap_tc, observed_condition_collar_tc) # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # DGA test modifier ------------------------------------------------------- dga_test_mod <- dga_test_modifier(hydrogen, methane, ethylene, ethane, acetylene, hydrogen_pre, methane_pre, ethylene_pre, ethane_pre, acetylene_pre) # FFA test modifier ------------------------------------------------------- ffa_test_mod <- ffa_test_modifier(furfuraldehyde) # Health score factor --------------------------------------------------- health_score_factor_for_tf <- gb_ref$health_score_factor_for_tf health_score_factor_tapchanger <- gb_ref$health_score_factor_tapchanger # Transformer factor_divider_1_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Tapchanger factor_divider_1_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- # Transformer obs_tf_factor <- observed_condition_modifier_tf$observed_condition_factor_tf mea_tf_factor <- measured_condition_modifier_tf$measured_condition_factor_tf oil_factor <- oil_test_mod$oil_condition_factor dga_factor <- dga_test_mod$dga_test_factor ffa_factor <- ffa_test_mod$ffa_test_factor factors_tf_health <- c(obs_tf_factor, mea_tf_factor, oil_factor, dga_factor, ffa_factor) health_score_factor_tf <- mmi(factors_tf_health, factor_divider_1_tf_health, factor_divider_2_tf_health, max_no_combined_factors_tf_health) # tapchanger obs_tc_factor <- observed_condition_modifier_tc$observed_condition_factor_tc mea_tc_factor <- measured_condition_modifier_tc$measured_condition_factor_tc factors_tc_health <- c(obs_tc_factor, mea_tc_factor, oil_factor) health_score_factor_tc <- mmi(factors_tc_health, factor_divider_1_tc_health, factor_divider_2_tc_health, max_no_combined_factors_tc_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap_tf <- min(observed_condition_modifier_tf$observed_condition_cap_tf, measured_condition_modifier_tf$measured_condition_cap_tf, oil_test_mod$oil_condition_cap, dga_test_mod$dga_test_cap, ffa_test_mod$ffa_test_cap) # Tapchanger health_score_cap_tc <- min(observed_condition_modifier_tc$observed_condition_cap_tc, measured_condition_modifier_tc$measured_condition_cap_tc, oil_test_mod$oil_condition_cap) # Health score collar ----------------------------------------------------- # Transformer health_score_collar_tf <- max(observed_condition_modifier_tf$observed_condition_collar_tf, measured_condition_modifier_tf$measured_condition_collar_tf, oil_test_mod$oil_condition_collar, dga_test_mod$dga_test_collar, ffa_test_mod$ffa_test_collar) # Tapchanger health_score_collar_tc <- max(observed_condition_modifier_tc$observed_condition_collar_tc, measured_condition_modifier_tc$measured_condition_collar_tc, oil_test_mod$oil_condition_collar) # Health score modifier --------------------------------------------------- # transformer health_score_modifier_tf <- data.frame(health_score_factor_tf, health_score_cap_tf, health_score_collar_tf) # Tapchanger health_score_modifier_tc <- data.frame(health_score_factor_tc, health_score_cap_tc, health_score_collar_tc) # Current health score ---------------------------------------------------- # Transformer current_health_score <- max(current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor), current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor)) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_transformer_30_60kv.R
#' @importFrom magrittr %>% #' @title Current Probability of Failure for 33/10kV and 66/10kV Transformers #' @description This function calculates the current #' annual probability of failure for 33/10kV and 66/10kV transformers. #' The function is a cubic curve that is based on #' the first three terms of the Taylor series for an #' exponential function. For more information about the #' probability of failure function see section 6 #' on page 34 in CNAIM (2021). #' @param transformer_type String. A sting that refers to the specific #' asset category. See See page 17, table 1 in CNAIM (2021). #' Options: #' \code{transformer_type = #' c("33kV Transformer (GM)", "66kV Transformer (GM)")}. The default setting is #' \code{transformer_type = "66kV Transformer (GM)"} #' @param year_of_manufacture Numeric. Normal expected life depends on the #' year for manufacture, see page 107 table 20 in CNAIM (2021). #' @inheritParams duty_factor_transformer_33_66kv #' @inheritParams location_factor #' @inheritParams current_health #' @param age_tf Numeric. The current age in years #' of the transformer. #' @param age_tc Numeric. The current age in years #' of the tapchanger #' @param partial_discharge_tf String. Indicating the #' level of partial discharge in the transformer. #' Options: #' \code{partial_discharge_tf = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. See page 154, table 173 in CNAIM (2021). #' @param partial_discharge_tc String. Indicating the #' level of partial discharge in the tapchanger #' Options: #' \code{partial_discharge_tc = c("Low", "Medium", "High (Not Confirmed)", #' "High (Confirmed)", "Default")}. See page 155, table 175 in CNAIM (2021). #' @param temperature_reading String. Indicating the criticality. #' Options: #' \code{temperature_reading = c("Normal", "Moderately High", #' "Very High", "Default")}. See page 154, table 174 in CNAIM (2021). #' @param main_tank String. Indicating the observed condition of the #' main tank. Options: #' \code{main_tank = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 131, table 83 #' in CNAIM (2021). #' @param coolers_radiator String. Indicating the observed condition of the #' coolers/radiators. Options: #' \code{coolers_radiator = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 131, table 84 #' in CNAIM (2021). #' @param bushings String. Indicating the observed condition of the #' bushings. Options: #' \code{bushings = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 131, table 85 #' in CNAIM (2021). #' @param kiosk String. Indicating the observed condition of the #' kiosk. Options: #' \code{kiosk = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 132, table 86 #' in CNAIM (2021). #' @param cable_boxes String. Indicating the observed condition of the #' cable boxes. Options: #' \code{cable_boxes = c("No Deterioration","Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 132, table 87 #' in CNAIM (2021). #' @param external_tap String. Indicating the observed external condition of the #' tapchanger. Options: #' \code{external_tap = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 133, table 88 #' in CNAIM (2021). #' @param internal_tap String. Indicating the observed internal condition of the #' tapchanger. Options: #' \code{internal_tap = c("Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 133, table 89 #' in CNAIM (2021). #' @param mechnism_cond String. Indicating the observed condition of the #' drive mechnism. Options: #' \code{mechnism_cond = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 133, table 90 #' in CNAIM (2021). #' @param diverter_contacts String. Indicating the observed condition of the #' selector and diverter contacts. Options: #' \code{diverter_contacts = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 133, table 91 #' in CNAIM (2021). #' @param diverter_braids String. Indicating the observed condition of the #' selector and diverter braids. Options: #' \code{diverter_braids = c("No deterioration", "Superficial/minor deterioration", "Some Deterioration", #' "Substantial Deterioration", "Default")}. See page 134, table 92 #' in CNAIM (2021) #' @param corrosion_category_index Integer. #' Specify the corrosion index category, 1-5. #' @param moisture Numeric. the amount of moisture given in (ppm) See page 162, table 203 in CNAIM (2021). #' @param acidity Numeric. the amount of acidicy given in (mg KOH/g) See page 162, table 204 in CNAIM (2021). #' @param bd_strength Numeric. the amount of breakdown strength given in (kV) See page 162, table 205 in CNAIM (2021). #' @inheritParams oil_test_modifier #' @inheritParams dga_test_modifier #' @inheritParams ffa_test_modifier #' @return DataFrame Current probability of failure #' per annum per kilometer along with current health score. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Current probability of failure for a 66/10kV transformer #' pof_transformer_33_66kv(transformer_type = "66kV Transformer (GM)", #' year_of_manufacture = 1980, #' utilisation_pct = "Default", #' no_taps = "Default", #' placement = "Default", #' altitude_m = "Default", #' distance_from_coast_km = "Default", #' corrosion_category_index = "Default", #' age_tf = 43, #' age_tc = 43, #' partial_discharge_tf = "Default", #' partial_discharge_tc = "Default", #' temperature_reading = "Default", #' main_tank = "Default", #' coolers_radiator = "Default", #' bushings = "Default", #' kiosk = "Default", #' cable_boxes = "Default", #' external_tap = "Default", #' internal_tap = "Default", #' mechnism_cond = "Default", #' diverter_contacts = "Default", #' diverter_braids = "Default", #' moisture = "Default", #' acidity = "Default", #' bd_strength = "Default", #' hydrogen = "Default", #' methane = "Default", #' ethylene = "Default", #' ethane = "Default", #' acetylene = "Default", #' hydrogen_pre = "Default", #' methane_pre = "Default", #' ethylene_pre = "Default", #' ethane_pre = "Default", #' acetylene_pre = "Default", #' furfuraldehyde = "Default", #' reliability_factor = "Default") pof_transformer_33_66kv <- function(transformer_type = "66kV Transformer (GM)", year_of_manufacture, utilisation_pct = "Default", no_taps = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", age_tf, age_tc, partial_discharge_tf = "Default", partial_discharge_tc = "Default", temperature_reading = "Default", main_tank = "Default", coolers_radiator = "Default", bushings = "Default", kiosk = "Default", cable_boxes = "Default", external_tap = "Default", internal_tap = "Default", mechnism_cond = "Default", diverter_contacts = "Default", diverter_braids = "Default", moisture = "Default", acidity = "Default", bd_strength = "Default", hydrogen = "Default", methane = "Default", ethylene = "Default", ethane = "Default", acetylene = "Default", hydrogen_pre = "Default", methane_pre = "Default", ethylene_pre = "Default", ethane_pre = "Default", acetylene_pre = "Default", furfuraldehyde = "Default", reliability_factor = "Default") { `Asset Register Category` = `Health Index Asset Category` = `Generic Term...1` = `Generic Term...2` = `Functional Failure Category` = `K-Value (%)` = `C-Value` = `Asset Register Category` = `Sub-division` = `Asset Category` = NULL # due to NSE notes in R CMD check # Ref. table Categorisation of Assets and Generic Terms for Assets -- asset_category <- gb_ref$categorisation_of_assets %>% dplyr::filter(`Asset Register Category` == transformer_type) %>% dplyr::select(`Health Index Asset Category`) %>% dplyr::pull() generic_term_1 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...1`) %>% dplyr::pull() generic_term_2 <- gb_ref$generic_terms_for_assets %>% dplyr::filter(`Health Index Asset Category` == asset_category) %>% dplyr::select(`Generic Term...2`) %>% dplyr::pull() # Normal expected life for transformer ----------------------------- if (year_of_manufacture < 1980) { sub_division <- "Transformer - Pre 1980" } else { sub_division <- "Transformer - Post 1980" } normal_expected_life_tf <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == sub_division) %>% dplyr::pull() # Normal expected life for tapchanger ----------------------------- normal_expected_life_tc <- gb_ref$normal_expected_life %>% dplyr::filter(`Asset Register Category` == transformer_type & `Sub-division` == "Tapchanger") %>% dplyr::pull() # Constants C and K for PoF function -------------------------------------- k <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`K-Value (%)`) %>% dplyr::pull()/100 c <- gb_ref$pof_curve_parameters %>% dplyr::filter(`Functional Failure Category` == 'EHV Transformer/ 132kV Transformer') %>% dplyr::select(`C-Value`) %>% dplyr::pull() # Duty factor ------------------------------------------------------------- duty_factor_tf_11kv <- duty_factor_transformer_33_66kv(utilisation_pct, no_taps) duty_factor_tf <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "transformer")] duty_factor_tc <- duty_factor_tf_11kv$duty_factor[which(duty_factor_tf_11kv$category == "tapchanger")] # Location factor ---------------------------------------------------- location_factor_transformer <- location_factor(placement, altitude_m, distance_from_coast_km, corrosion_category_index, asset_type = transformer_type) # Expected life for transformer ------------------------------ expected_life_years_tf <- expected_life(normal_expected_life = normal_expected_life_tf, duty_factor_tf, location_factor_transformer) # Expected life for tapchanger ------------------------------ expected_life_years_tc <- expected_life(normal_expected_life = normal_expected_life_tc, duty_factor_tc, location_factor_transformer) # b1 (Initial Ageing Rate) ------------------------------------------------ b1_tf <- beta_1(expected_life_years_tf) b1_tc <- beta_1(expected_life_years_tc) # Initial health score ---------------------------------------------------- initial_health_score_tf <- initial_health(b1_tf, age_tf) initial_health_score_tc <- initial_health(b1_tc, age_tc) ## NOTE # Typically, the Health Score Collar is 0.5 and # Health Score Cap is 10, implying no overriding # of the Health Score. However, in some instances # these parameters are set to other values in the # Health Score Modifier calibration tables. # These overriding values are shown in Table 35 to Table 202 # and Table 207 in Appendix B. # Measured condition inputs --------------------------------------------- mcm_mmi_cal_df <- gb_ref$measured_cond_modifier_mmi_cal mcm_mmi_cal_df <- mcm_mmi_cal_df[which(mcm_mmi_cal_df$`Asset Category` == "EHV Transformer (GM)"), ] factor_divider_1_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc <- as.numeric(mcm_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(mcm_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Partial discharge transformer ---------------------------------------------- mci_hv_tf_partial_discharge <- gb_ref$mci_ehv_tf_main_tf_prtl_dis ci_factor_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Factor`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_cap_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Cap`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] ci_collar_partial_discharge_tf <- mci_hv_tf_partial_discharge$`Condition Input Collar`[which( mci_hv_tf_partial_discharge$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tf)] # Partial discharge tapchanger ------------------------------------------------ mci_hv_tf_partial_discharge_tc <- gb_ref$mci_ehv_tf_tapchngr_prtl_dis ci_factor_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Factor`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_cap_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Cap`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] ci_collar_partial_discharge_tc <- mci_hv_tf_partial_discharge_tc$`Condition Input Collar`[which( mci_hv_tf_partial_discharge_tc$ `Condition Criteria: Partial Discharge Test Result` == partial_discharge_tc)] # Temperature readings ---------------------------------------------------- mci_hv_tf_temp_readings <- gb_ref$mci_ehv_tf_temp_readings ci_factor_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Factor`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_cap_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Cap`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] ci_collar_temp_reading <- mci_hv_tf_temp_readings$`Condition Input Collar`[which( mci_hv_tf_temp_readings$ `Condition Criteria: Temperature Reading` == temperature_reading)] # measured condition factor ----------------------------------------------- factors_tf <- c(ci_factor_partial_discharge_tf, ci_factor_temp_reading) measured_condition_factor_tf <- mmi(factors_tf, factor_divider_1_tf, factor_divider_2_tf, max_no_combined_factors_tf) measured_condition_factor_tc <- mmi(ci_factor_partial_discharge_tc, factor_divider_1_tc, factor_divider_2_tc, max_no_combined_factors_tc) # Measured condition cap -------------------------------------------------- caps_tf <- c(ci_cap_partial_discharge_tf, ci_cap_temp_reading) measured_condition_cap_tf <- min(caps_tf) measured_condition_cap_tc <- ci_cap_partial_discharge_tc # Measured condition collar ----------------------------------------------- collars_tf <- c(ci_collar_partial_discharge_tf, ci_collar_temp_reading) measured_condition_collar_tf <- max(collars_tf) measured_condition_collar_tc <- ci_collar_partial_discharge_tc # Measured condition modifier --------------------------------------------- measured_condition_modifier_tf <- data.frame(measured_condition_factor_tf, measured_condition_cap_tf, measured_condition_collar_tf) measured_condition_modifier_tc <- data.frame(measured_condition_factor_tc, measured_condition_cap_tc, measured_condition_collar_tc) # Observed condition inputs --------------------------------------------- oci_mmi_cal_df <- gb_ref$observed_cond_modifier_mmi_cal %>% dplyr::filter(`Asset Category` == "EHV Transformer (GM)") factor_divider_1_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_1_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 1`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) factor_divider_2_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) factor_divider_2_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Factor Divider 2`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) max_no_combined_factors_tf_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Main Transformer") ]) max_no_combined_factors_tc_obs <- as.numeric(oci_mmi_cal_df$`Parameters for Combination Using MMI Technique - Max. No. of Combined Factors`[ which(oci_mmi_cal_df$Subcomponent == "Tapchanger") ]) # Transformer ------------------------------------------------------------- # Main tank condition oci_ehv_tf_main_tank_cond <- gb_ref$oci_ehv_tf_main_tank_cond Oi_collar_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Collar`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_cap_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Cap`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] Oi_factor_main_tank <- oci_ehv_tf_main_tank_cond$`Condition Input Factor`[which( oci_ehv_tf_main_tank_cond$`Condition Criteria: Observed Condition` == main_tank)] # Coolers/Radiator condition oci_ehv_tf_cooler_radiatr_cond <- gb_ref$oci_ehv_tf_cooler_radiatr_cond Oi_collar_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Collar`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_cap_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Cap`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] Oi_factor_coolers_radiator <- oci_ehv_tf_cooler_radiatr_cond$`Condition Input Factor`[which( oci_ehv_tf_cooler_radiatr_cond$`Condition Criteria: Observed Condition` == coolers_radiator)] # Bushings oci_ehv_tf_bushings_cond <- gb_ref$oci_ehv_tf_bushings_cond Oi_collar_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Collar`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_cap_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Cap`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] Oi_factor_bushings <- oci_ehv_tf_bushings_cond$`Condition Input Factor`[which( oci_ehv_tf_bushings_cond$`Condition Criteria: Observed Condition` == bushings)] # Kiosk oci_ehv_tf_kiosk_cond <- gb_ref$oci_ehv_tf_kiosk_cond Oi_collar_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Collar`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_cap_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Cap`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] Oi_factor_kiosk <- oci_ehv_tf_kiosk_cond$`Condition Input Factor`[which( oci_ehv_tf_kiosk_cond$`Condition Criteria: Observed Condition` == kiosk)] # Cable box oci_ehv_tf_cable_boxes_cond <- gb_ref$oci_ehv_tf_cable_boxes_cond Oi_collar_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Collar`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_cap_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Cap`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] Oi_factor_cable_boxes <- oci_ehv_tf_cable_boxes_cond$`Condition Input Factor`[which( oci_ehv_tf_cable_boxes_cond$`Condition Criteria: Observed Condition` == cable_boxes)] # Tapchanger -------------------------------------------------------------- # External condition oci_ehv_tf_tapchanger_ext_cond <- gb_ref$oci_ehv_tf_tapchanger_ext_cond Oi_collar_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Collar`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_cap_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Cap`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] Oi_factor_external_tap <- oci_ehv_tf_tapchanger_ext_cond$`Condition Input Factor`[which( oci_ehv_tf_tapchanger_ext_cond$`Condition Criteria: Observed Condition` == external_tap)] # Internal condition oci_ehv_tf_int_cond <- gb_ref$oci_ehv_tf_int_cond Oi_collar_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Collar`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_cap_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Cap`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] Oi_factor_internal_tap <- oci_ehv_tf_int_cond$`Condition Input Factor`[which( oci_ehv_tf_int_cond$`Condition Criteria: Observed Condition` == internal_tap)] # Drive mechanism oci_ehv_tf_drive_mechnism_cond <- gb_ref$oci_ehv_tf_drive_mechnism_cond Oi_collar_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Collar`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_cap_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Cap`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] Oi_factor_mechnism_cond <- oci_ehv_tf_drive_mechnism_cond$`Condition Input Factor`[which( oci_ehv_tf_drive_mechnism_cond$`Condition Criteria: Observed Condition` == mechnism_cond)] # Selecter diverter contacts oci_ehv_tf_cond_select_divrter_cst <- gb_ref$oci_ehv_tf_cond_select_div_cts Oi_collar_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_cap_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] Oi_factor_diverter_contacts <- oci_ehv_tf_cond_select_divrter_cst$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_cst$`Condition Criteria: Observed Condition` == diverter_contacts)] # Selecter diverter braids oci_ehv_tf_cond_select_divrter_brd <- gb_ref$oci_ehv_tf_cond_select_div_brd Oi_collar_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Collar`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_cap_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Cap`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] Oi_factor_diverter_braids <- oci_ehv_tf_cond_select_divrter_brd$`Condition Input Factor`[which( oci_ehv_tf_cond_select_divrter_brd$`Condition Criteria: Observed Condition` == diverter_braids)] # Observed condition factor -------------------------------------- # Transformer factors_tf_obs <- c(Oi_factor_main_tank, Oi_factor_coolers_radiator, Oi_factor_bushings, Oi_factor_kiosk, Oi_factor_cable_boxes) observed_condition_factor_tf <- mmi(factors_tf_obs, factor_divider_1_tf_obs, factor_divider_2_tf_obs, max_no_combined_factors_tf_obs) # Tapchanger factors_tc_obs <- c(Oi_factor_external_tap, Oi_factor_internal_tap, Oi_factor_mechnism_cond, Oi_factor_diverter_contacts, Oi_factor_diverter_braids) observed_condition_factor_tc <- mmi(factors_tc_obs, factor_divider_1_tc_obs, factor_divider_2_tc_obs, max_no_combined_factors_tc_obs) # Observed condition cap ----------------------------------------- # Transformer caps_tf_obs <- c(Oi_cap_main_tank, Oi_cap_coolers_radiator, Oi_cap_bushings, Oi_cap_kiosk, Oi_cap_cable_boxes) observed_condition_cap_tf <- min(caps_tf_obs) # Tapchanger caps_tc_obs <- c(Oi_cap_external_tap, Oi_cap_internal_tap, Oi_cap_mechnism_cond, Oi_cap_diverter_contacts, Oi_cap_diverter_braids) observed_condition_cap_tc <- min(caps_tc_obs) # Observed condition collar --------------------------------------- # Transformer collars_tf_obs <- c(Oi_collar_main_tank, Oi_collar_coolers_radiator, Oi_collar_bushings, Oi_collar_kiosk, Oi_collar_cable_boxes) observed_condition_collar_tf <- max(collars_tf_obs) # Tapchanger collars_tc_obs <- c(Oi_collar_external_tap, Oi_collar_internal_tap, Oi_collar_mechnism_cond, Oi_collar_diverter_contacts, Oi_collar_diverter_braids) observed_condition_collar_tc <- max(collars_tc_obs) # Observed condition modifier --------------------------------------------- # Transformer observed_condition_modifier_tf <- data.frame(observed_condition_factor_tf, observed_condition_cap_tf, observed_condition_collar_tf) # Tapchanger observed_condition_modifier_tc <- data.frame(observed_condition_factor_tc, observed_condition_cap_tc, observed_condition_collar_tc) # Oil test modifier ------------------------------------------------------- oil_test_mod <- oil_test_modifier(moisture, acidity, bd_strength) # DGA test modifier ------------------------------------------------------- dga_test_mod <- dga_test_modifier(hydrogen, methane, ethylene, ethane, acetylene, hydrogen_pre, methane_pre, ethylene_pre, ethane_pre, acetylene_pre) # FFA test modifier ------------------------------------------------------- ffa_test_mod <- ffa_test_modifier(furfuraldehyde) # Health score factor --------------------------------------------------- health_score_factor_for_tf <- gb_ref$health_score_factor_for_tf health_score_factor_tapchanger <- gb_ref$health_score_factor_tapchanger # Transformer factor_divider_1_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tf_health <- health_score_factor_for_tf$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Tapchanger factor_divider_1_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 1` factor_divider_2_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Factor Divider 2` max_no_combined_factors_tc_health <- health_score_factor_tapchanger$`Parameters for Combination Using MMI Technique - Max. No. of Condition Factors` # Health score modifier ----------------------------------------------------- # Transformer obs_tf_factor <- observed_condition_modifier_tf$observed_condition_factor_tf mea_tf_factor <- measured_condition_modifier_tf$measured_condition_factor_tf oil_factor <- oil_test_mod$oil_condition_factor dga_factor <- dga_test_mod$dga_test_factor ffa_factor <- ffa_test_mod$ffa_test_factor factors_tf_health <- c(obs_tf_factor, mea_tf_factor, oil_factor, dga_factor, ffa_factor) health_score_factor_tf <- mmi(factors_tf_health, factor_divider_1_tf_health, factor_divider_2_tf_health, max_no_combined_factors_tf_health) # tapchanger obs_tc_factor <- observed_condition_modifier_tc$observed_condition_factor_tc mea_tc_factor <- measured_condition_modifier_tc$measured_condition_factor_tc factors_tc_health <- c(obs_tc_factor, mea_tc_factor, oil_factor) health_score_factor_tc <- mmi(factors_tc_health, factor_divider_1_tc_health, factor_divider_2_tc_health, max_no_combined_factors_tc_health) # Health score cap -------------------------------------------------------- # Transformer health_score_cap_tf <- min(observed_condition_modifier_tf$observed_condition_cap_tf, measured_condition_modifier_tf$measured_condition_cap_tf, oil_test_mod$oil_condition_cap, dga_test_mod$dga_test_cap, ffa_test_mod$ffa_test_cap) # Tapchanger health_score_cap_tc <- min(observed_condition_modifier_tc$observed_condition_cap_tc, measured_condition_modifier_tc$measured_condition_cap_tc, oil_test_mod$oil_condition_cap) # Health score collar ----------------------------------------------------- # Transformer health_score_collar_tf <- max(observed_condition_modifier_tf$observed_condition_collar_tf, measured_condition_modifier_tf$measured_condition_collar_tf, oil_test_mod$oil_condition_collar, dga_test_mod$dga_test_collar, ffa_test_mod$ffa_test_collar) # Tapchanger health_score_collar_tc <- max(observed_condition_modifier_tc$observed_condition_collar_tc, measured_condition_modifier_tc$measured_condition_collar_tc, oil_test_mod$oil_condition_collar) # Health score modifier --------------------------------------------------- # transformer health_score_modifier_tf <- data.frame(health_score_factor_tf, health_score_cap_tf, health_score_collar_tf) # Tapchanger health_score_modifier_tc <- data.frame(health_score_factor_tc, health_score_cap_tc, health_score_collar_tc) # Current health score ---------------------------------------------------- # Transformer current_health_score <- max(current_health(initial_health_score_tf, health_score_modifier_tf$health_score_factor_tf, health_score_modifier_tf$health_score_cap_tf, health_score_modifier_tf$health_score_collar, reliability_factor = reliability_factor), current_health(initial_health_score_tf, health_score_modifier_tc$health_score_factor_tc, health_score_modifier_tc$health_score_cap_tc, health_score_modifier_tc$health_score_collar_tc, reliability_factor = reliability_factor)) # Probability of failure for the 6.6/11 kV transformer today ----------------- probability_of_failure <- k * (1 + (c * current_health_score) + (((c * current_health_score)^2) / factorial(2)) + (((c * current_health_score)^3) / factorial(3))) return(data.frame(pof = probability_of_failure, chs = current_health_score)) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/pof_transformer_33_66kv.R
#' @title Present Value of Future Risk #' @description This function calculates the present value of future risk. #' See section 5.5 on page 32 in CNAIM (2021). #' @param pof A vector of the probability of failure of the asset over years #' @param cof The consequence of failure of the asset #' @param r discount rate #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #'\url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' present_value_future_risk(c(0.1, 0.2, 0.5), 100) present_value_future_risk <- function(pof, cof, r = 0.035) { n <- length(pof) sum_pof <- lapply(1:length(pof), function(i){ pof[i] * (1+r)^(-i) }) %>% unlist() %>% sum() return(sum_pof * cof) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/present_value_of_future_risk.R
#' @title Calculates risk and converts to matrix coordinates #' @description This function calculates risk matrix coordinates #' dimensions. #' @param matrix_dimensions A data frame with the dimensions of the desired risk #' matrix. #' @param id An integer that identifies the asset #' @param chs The Current Health Score (CHS) of the asset #' @param cof The Consequence of Failure of the asset #' @param asset_type The asset type to be calculated for class #' @param hi_bands Specific Health Index (HI) bands for risk matrix. Default #' values are the same as defined in the CNAIM v2.1 standard #' @param ci_bands Specific Criticality Index (CI) bands for the risk matrix. #' Default values are the same as defined in the CNAIM v.2.1 standard. #' @param asset_type The asset type to be calculated for class #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Calculate risk matrix coordinates for an asset #' # 1. Make the risk matrix structure #' matrix_structure <- risk_matrix_structure(5,4,NA) #' #' # 2. Calculate risk matrix coordinates #' risk_calculation(matrix_dimensions = matrix_structure, #' id = 1, #' chs = 4, #' cof = 15000, #' asset_type = "6.6/11kV Transformer (GM)") #' #' risk_calculation <- function(matrix_dimensions,id,chs,cof,asset_type, hi_bands = NULL, ci_bands = NULL){ `Asset Register Category` = `Total - (GBP)` = NULL # due to NSE notes in R CMD check reference_cof <- gb_ref$reference_costs_of_failure %>% dplyr::filter(`Asset Register Category` == asset_type) %>% dplyr::select(`Total - (GBP)`) %>% dplyr::pull() if (is.null(hi_bands)){hi_bands <- c(3, 5, 5.5, 6.5, 8, 15)} if (is.null(ci_bands)){ci_bands <- c(75, 125, 200, Inf)} ci <- (cof/reference_cof)*100 for (i in 1:length(hi_bands)) { if(chs < hi_bands[i] && i==1) { pof_pct <- ((chs - 0.5) / (hi_bands[i]-0.5)) * (100/length(hi_bands)) break } else if (chs < hi_bands[i] ) { pof_pct <- ((chs - hi_bands[i-1]) / (hi_bands[i]-hi_bands[i-1])) * (100/length(hi_bands)) + (100/length(hi_bands))*(i-1) break } else if (chs > 15) { pof_pct <- 100 } } for (i in 1:length(ci_bands)) { if(ci < ci_bands[i] && i==1) { cof_pct <- ((ci - 0) / (ci_bands[i]- 0)) * (100/length(ci_bands)) break } else if (ci < ci_bands[i] ) { cof_pct <- ((ci - ci_bands[i-1]) / (ci_bands[i]-ci_bands[i-1])) * (100/length(ci_bands)) + (100/length(ci_bands))*(i-1) break } else if (ci > 250) { cof_pct <- 100 } } # pof_pct <- pof # Criteria for being changed # Upper band is cof*4 # if (pof_pct > 15) pof_pct <- 15 # if (cof_pct > 250) cof_pct <- 250 dots_vector = data.frame(id = id, point_x = pof_pct, point_y = cof_pct) return(dots_vector) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/risk_calculation.R
#' @title Make a risk matrix with individual asset points #' @description This function makes a D3 visualization of monetary risk with #' each asset as a point on the grid. #' @param risk_data_matrix Long format matrix data. #' @param dots_vector Coordinates of the dots. #' @param dot_radius Radius of the dots. #' @export #' risk_matrix_points_plot <- function(risk_data_matrix, dots_vector, dot_radius){ # risk_matrix_points(CNAIM:::example_risk_matrix) adj_mat_1 = matrix_adjusted_circles(risk_data_matrix, dots_vector, dot_radius) risk_matrix <- r2d3::r2d3( data = jsonlite::toJSON(adj_mat_1), script = "javascript/src/matrix_upper_level_circles.js", dependencies = "javascript/src/matrix_d3script_circles_aa.js", container = "div" ) risk_matrix }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/risk_matrix_points_plot.R
#' @title Makes a default risk matrix structure #' @description This function makes a simple matrix structure that can be used #' as an input to the risk_matrix_points and risk_matrix_summary functions #' @param cols Number of columns #' @param rows Number of rows #' @param value Default value of each cell #' @export #' risk_matrix_structure <- function(cols,rows,value=NA){ risk_data_matrix <- expand.grid(x = 1:cols, y = 1:rows) risk_data_matrix$value <- value return(risk_data_matrix) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/risk_matrix_structure.R
#' @title Make a risk matrix with non-linear spacing #' @description This function makes a D3 visualization of monetary risk with #' non-linear x and y intervals. #' @param risk_data_matrix Long format matrix data. #' @param x_intervals An array of x spacing in percent (sum to 100) #' @param y_intervals An array of y spacing in percent (sum to 100) #' @export risk_matrix_summary_plot <- function(risk_data_matrix, x_intervals = rep(20,5), y_intervals = rep(25,4)){ # risk_matrix_summary(CNAIM:::example_risk_matrix) if (is.null(risk_data_matrix$mouse_over_text) & max(risk_data_matrix$x) == 5 & max(risk_data_matrix$y) == 4){ risk_data_matrix$mouse_over_text <- example_risk_matrix$mouse_over_text } # Non-linear bins ------- x_intervals = x_intervals/sum(x_intervals) x_intervals = round(x_intervals,2) y_intervals = y_intervals/sum(y_intervals) y_intervals = round(y_intervals,2) adj_mat_2 = matrix_adjusted_intervals(risk_data_matrix,x_intervals,y_intervals) risk_matrix <- r2d3::r2d3( data = jsonlite::toJSON(adj_mat_2), script = "javascript/src/matrix_upper_level_nonlinear.js", dependencies = "javascript/src/matrix_d3script_nonlinear_aa.js", container = "div" ) risk_matrix }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/risk_matrix_summary_plot.R
#' @title Safety Consequences of Failure for Switchgears, Transformers & #' Overhead Lines #' @description This function calculates safety consequences of failure #' for switchgear, transformers and overhead lines #' (cf. section 7.4, page 80, CNAIM, 2021). Safety consequences of failure #' is used in the derivation of consequences of failure see \code{\link{cof}}(). #' @param type_risk String. Risk that the asset presents to the #' public by its characteristics and particular situation. Options: #' \code{type_risk = c("Low", "Medium", "High", "Default")} #' (cf. table 225, page 183, CNAIM, 2021). #' A setting of \code{"Default"} equals a setting of \code{"Medium"}. #' @param location_risk String. Proximity to areas that may affect its #' likelihood of trespass or interference. Options: #' \code{location_risk = c("Low", "Medium", "High", "Default")} #' (cf. table 225, page 183, CNAIM, 2021). #' A setting of \code{"Default"} equals a setting of \code{"Medium"}. #' @param asset_type_scf String. #' Options: #' \code{asset_type_scf = c("LV Poles", "LV Circuit Breaker", #' "LV Pillar (ID)", "LV Pillar (OD at Substation)", #' "LV Pillar (OD not at a Substation)", "LV Board (WM)", #' "LV UGB", "LV Board (X-type Network) (WM)", "6.6/11kV Poles", #' "20kV Poles", "6.6/11kV CB (GM) Primary", #' "6.6/11kV CB (GM) Secondary", "6.6/11kV Switch (GM)", "6.6/11kV RMU", #' "6.6/11kV X-type RMU", "20kV CB (GM) Primary", "20kV CB (GM) Secondary", #' "20kV Switch (GM)", "20kV RMU", "6.6/11kV Transformer (GM)", #' "20kV Transformer (GM)", "33kV Pole", "66kV Pole", #' "33kV OHL (Tower Line) Conductor", "33kV Tower", "33kV Fittings", #' "66kV OHL (Tower Line) Conductor", "66kV Tower", "66kV Fittings", #' "33kV CB (Air Insulated Busbars)(ID) (GM)", #' "33kV CB (Air Insulated Busbars)(OD) (GM)", #' "33kV CB (Gas Insulated Busbars)(ID) (GM)", #' "33kV CB (Gas Insulated Busbars)(OD) (GM)", "33kV Switch (GM)", #' "33kV RMU", "66kV CB (Air Insulated Busbars)(ID) (GM)", #' "66kV CB (Air Insulated Busbars)(OD) (GM)", #' "66kV CB (Gas Insulated Busbars)(ID) (GM)", #' "66kV CB (Gas Insulated Busbars)(OD) (GM)", "33kV Transformer (GM)", #' "66kV Transformer (GM)", "132kV OHL (Tower Line) Conductor", #' "132kV Tower", "132kV Fittings", #' "132kV CB (Air Insulated Busbars)(ID) (GM)", #' "132kV CB (Air Insulated Busbars)(OD) (GM)", #' "132kV CB (Gas Insulated Busbars)(ID) (GM)", #' "132kV CB (Gas Insulated Busbars)(OD) (GM)", "132kV Transformer (GM)") #'} #' @return Numeric. Safety consequences of failure for #' switchgear, transformers and overhead lines. #' @source DNO Common Network Asset Indices Methodology (CNAIM), #' Health & Criticality - Version 2.1, 2021: #' \url{https://www.ofgem.gov.uk/sites/default/files/docs/2021/04/dno_common_network_asset_indices_methodology_v2.1_final_01-04-2021.pdf} #' @export #' @examples #' # Safety consequences failure for a 6.6/11 kV transformer #' s_cof_swg_tf_ohl(type_risk = "Default", location_risk = "Default", #' asset_type_scf = "6.6/11kV Transformer (GM)") s_cof_swg_tf_ohl <- function(type_risk = "Default", location_risk = "Default", asset_type_scf) { `Asset Register Category` = NULL # due to NSE notes in R CMD check # Get category ------------------------------------------------------------ reference_costs_of_failure_tf <- dplyr::filter(gb_ref$reference_costs_of_failure, `Asset Register Category` == asset_type_scf) # Reference safety cost of failure ---------------------------------------- scost <- reference_costs_of_failure_tf$`Safety - (GBP)` # Safety Consequence factor ---------------------------------------------- safety_conseq_factor_sg_tf_oh <- gb_ref$safety_conseq_factor_sg_tf_oh if (location_risk == "Default") location_risk <- "Medium (Default)" if (location_risk == "Medium") location_risk <- "Medium (Default)" if (type_risk == "Default") type_risk <- "Medium" row_no <- which(safety_conseq_factor_sg_tf_oh$ `Safety Consequence Factor - Switchgear, Transformers & Overhead Lines...2` == location_risk) col_no <- grep(type_risk, colnames(safety_conseq_factor_sg_tf_oh)) safety_consequence_factor <- safety_conseq_factor_sg_tf_oh[row_no, col_no] # Safety consequence of failure ------------------------------------------- safety_cof <- safety_consequence_factor * scost return(safety_cof) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/s_cof_swg_tf_ohl.R
#' @importFrom stats dweibull lm uniroot #' @title Prediction function for Weibull model #' @description This function uses the Weibull model parameters trained by the function \code{\link{train_weibull_model}}(), together #' with the environmental factors for a specific transformer, and determines the probability of failure at a given age. #' @param age Numeric. Age of transformer which should be used in the prediction. #' @param environmental_factors Data frame. Must contain the following fields: #' utilisation_pct: Numeric or "Default", #' placement: "Indoor", "Outdoor" or "Default", #' altitude_m: Numeric or "Default", #' distance_from_coast_km: Numeric or "Default", #' corrosion_category_index: Numeric or "Default", #' partial_discharge: "Low", "Medium", "High (Not Confirmed)", "High (Confirmed)" or "Default", #' oil_acidity: Numeric or "Default", #' temperature_reading: "Normal", "Moderately High", "Very High" or "Default", #' observed_condition: "No deterioration", "Superficial/minor deterioration", "Slight Deterioration", "Some deterioration", "Substantial deterioration" or "Default" #' Default value if environmental_factors is not provided: data frame with value "Default" for all fields #' @param weibull_model_parameters Data frame. The output returned by the function #' \code{\link{train_weibull_model}}(). #' Default value if weibull_parameters is not provided: data frame with parameters trained on data set transformer_11kv_faults.rda #' @return Numeric. Probability of failure at the given age. #' @source \url{https://www.cnaim.io/docs/fault-analysis/} #' @export #' @examples #' predict_weibull_model(age = 50) #' predict_weibull_model <- function(age, environmental_factors = data.frame(utilisation_pct = "Default", placement = "Default", altitude_m = "Default", distance_from_coast_km = "Default", corrosion_category_index = "Default", partial_discharge = "Default", oil_acidity = "Default", temperature_reading = "Default", observed_condition = "Default"), weibull_model_parameters = data.frame(shapes = c(3.597272, 2.528015, 2.273607, 2.101450, 2.048909), scales.intercept = c(100.17922, 45.54622, 73.63507, 29.99655, 31.19306), scales.1 = c(0.0028536801, 0.0014449054, 0.0011716558, -0.0003356626, -0.0017302242), scales.2 = c(-8.202209, -3.856043, -2.818854, -2.388243, -2.940468), scales.3 = c(-0.003023546, -0.001602048, -0.001348340, -0.001988660, -0.003149921), scales.4 = c(-0.040016081, -0.028129483, -0.017586604, -0.009426902, -0.021783120), scales.5 = c(-1.4776137, -0.6794045, -0.6000869, -0.3839049, -0.4445468), scales.6 = c(-0.811395564, 0.015705206, -9.815935489, -0.002548827, -0.085903822), scales.7 = c(-4.4776511, -0.3677058, 0.4590218, -0.6364809, -0.3314029), scales.8 = c(-1.5861982, 0.0000000, -0.1398528, -0.1721091, 0.0000000), scales.9 = c(-0.7914404, -0.2632199, -1.1882148, 0.0000000, 0.0000000)) ) { EF <- environmental_factors WP <- weibull_model_parameters # need numerical representation of the data: EF_num <- data.frame(0) # 1. utilisation percentage if (EF$utilisation_pct == "Default") EF_num$utilisation_pct <- 85 else EF_num$utilisation_pct <- EF$utilisation_pct # 2. placement EF_num$placement[EF$placement %in% c("Indoor", "Default")] <- 1 EF_num$placement[EF$placement == "Outdoor"] <- 2 # 3. altitude in meters if (EF$altitude_m == "Default") EF_num$altitude_m <- 150 else EF_num$altitude_m <- EF$altitude_m # 4. distance from coast in km if (EF$distance_from_coast_km == "Default") EF_num$distance_from_coast_km <- 15 else EF_num$distance_from_coast_km <- EF$distance_from_coast_km # 5. corrosion category index if (EF$corrosion_category_index == "Default") EF_num$corrosion_category_index <- 3 else EF_num$corrosion_category_index <- as.numeric(EF$corrosion_category_index) # 6. partial discharge EF_num$partial_discharge[EF$partial_discharge %in% c("Low", "Default")] <- 1 EF_num$partial_discharge[EF$partial_discharge == "Medium"] <- 2 EF_num$partial_discharge[EF$partial_discharge == "High (Not Confirmed)"] <- 3 EF_num$partial_discharge[EF$partial_discharge == "High (Confirmed)"] <- 4 # 7. oil acidity if (EF$oil_acidity == "Default") EF_num$oil_acidity <- 0.25 else EF_num$oil_acidity <- EF$oil_acidity # 8. temperature reading EF_num$temperature_reading[EF$temperature_reading %in% c("Normal", "Default")] <- 1 EF_num$temperature_reading[EF$temperature_reading == "Moderately High"] <- 2 EF_num$temperature_reading[EF$temperature_reading == "Very High"] <- 3 # 9. observed condition EF_num$observed_condition[EF$observed_condition == "No deterioration"] <- 1 EF_num$observed_condition[EF$observed_condition %in% c("Superficial/minor deterioration", "Default")] <- 2 EF_num$observed_condition[EF$observed_condition == "Slight Deterioration"] <- 3 EF_num$observed_condition[EF$observed_condition == "Some deterioration"] <- 4 EF_num$observed_condition[EF$observed_condition == "Substantial deterioration"] <- 5 # find which part of the partition the data point is in:: if (EF_num$partial_discharge %in% c(3,4)) { idx <- 3 } else { if (EF_num$temperature_reading == 3) { if (EF_num$observed_condition == 5) { idx <- 5 } else { idx <- 2 } } else { if (EF_num$observed_condition == 5) { idx <- 4 } else { idx <- 1 } } } # calculate scale parameter from multilinear fit, then use the Weibull distribution with the trained scale # and shape parameters to find the probability of failure: scale = WP$scales.intercept[idx] + WP$scales.1[idx] * EF_num$utilisation_pct + WP$scales.2[idx] * EF_num$placement + WP$scales.3[idx] * EF_num$altitude_m + WP$scales.4[idx] * EF_num$distance_from_coast_km + WP$scales.5[idx] * EF_num$corrosion_category_index + WP$scales.6[idx] * EF_num$partial_discharge + WP$scales.7[idx] * EF_num$oil_acidity + WP$scales.8[idx] * EF_num$temperature_reading + WP$scales.9[idx] * EF_num$observed_condition pof <- dweibull(age, WP$shapes[idx], scale) return(pof) } #' @title Training function for Weibull model #' @description This function uses transformer fault statistics data to train a Weibull model: Based on the environmental #' factors determining a transformer's expected lifetime, the set of all data points is first partitioned into five parts. #' Then a multilinear estimate for the expected lifetime of a transformer is trained for each part separately, and the #' corresponding Weibull shape and scale parameters for the five parts are estimated. The function returns the shape and scale #' parameters needed for the function \code{\link{predict_weibull_model}}(). #' @param transformer_faults_data Data frame. Contains past data on transformer faults, together with environmental factors. #' Must contain the following fields: #' utilisation_pct: Numeric or "Default", #' placement: "Indoor", "Outdoor" or "Default", #' altitude_m: Numeric or "Default", #' distance_from_coast_km: Numeric or "Default", #' corrosion_category_index: Numeric or "Default", #' partial_discharge: "Low", "Medium", "High (Not Confirmed)", "High (Confirmed)" or "Default", #' oil_acidity: Numeric or "Default", #' temperature_reading: "Normal", "Moderately High", "Very High" or "Default", #' observed_condition: "No deterioration", "Superficial/minor deterioration", "Slight Deterioration", "Some deterioration", "Substantial deterioration" or "Default" #' age: Numeric #' @return Data frame. All shape and scale parameters needed for the function \code{\link{predict_weibull_model}}(). #' @source \url{https://www.cnaim.io/docs/fault-analysis/} #' @export #' @examples #' train_weibull_model(transformer_faults_data = transformer_11kv_faults) #' train_weibull_model <- function(transformer_faults_data) { # need numerical representation of the data: TF <- transformer_faults_data # 1. utilisation percentage TF_num <- data.frame(utilisation_pct = TF$utilisation_pct) TF_num$utilisation_pct[TF$utilisation_pct == "Default"] <- 85 # 2. placement TF_num$placement[TF$placement %in% c("Indoor", "Default")] <- 1 TF_num$placement[TF$placement == "Outdoor"] <- 2 # 3. altitude in meters TF_num$altitude_m <- TF$altitude_m TF_num$altitude_m[TF$altitude_m == "Default"] <- 150 # 4. distance from coast in km TF_num$distance_from_coast_km <- TF$distance_from_coast_km TF_num$distance_from_coast_km[TF$distance_from_coast_km == "Default"] <- 15 # 5. corrosion category index TF_num$corrosion_category_index <- as.numeric(TF$corrosion_category_index) TF_num$corrosion_category_index[TF$corrosion_category_index == "Default"] <- 3 # 6. partial discharge TF_num$partial_discharge[TF$partial_discharge %in% c("Low", "Default")] <- 1 TF_num$partial_discharge[TF$partial_discharge == "Medium"] <- 2 TF_num$partial_discharge[TF$partial_discharge == "High (Not Confirmed)"] <- 3 TF_num$partial_discharge[TF$partial_discharge == "High (Confirmed)"] <- 4 # 7. oil acidity TF_num$oil_acidity <- TF$oil_acidity TF_num$oil_acidity[TF$oil_acidity == "Default"] <- 0.25 # 8. temperature reading TF_num$temperature_reading[TF$temperature_reading %in% c("Normal", "Default")] <- 1 TF_num$temperature_reading[TF$temperature_reading == "Moderately High"] <- 2 TF_num$temperature_reading[TF$temperature_reading == "Very High"] <- 3 # 9. observed condition TF_num$observed_condition[TF$observed_condition == "No deterioration"] <- 1 TF_num$observed_condition[TF$observed_condition %in% c("Superficial/minor deterioration", "Default")] <- 2 TF_num$observed_condition[TF$observed_condition == "Slight Deterioration"] <- 3 TF_num$observed_condition[TF$observed_condition == "Some deterioration"] <- 4 TF_num$observed_condition[TF$observed_condition == "Substantial deterioration"] <- 5 # 10. age TF_num$age <- TF$age # partitioning the data into 5 bins according to the most relevant environmental factors: H1_data <- TF_num[! TF_num$partial_discharge %in% c(3,4),] H1_data <- H1_data[! H1_data$temperature_reading %in% c(3), ] H1_data <- H1_data[! H1_data$observed_condition %in% c(5), ] H2_data <- TF_num[! TF_num$partial_discharge %in% c(3,4),] H2_data <- H2_data[H2_data$temperature_reading %in% c(3), ] H2_data <- H2_data[!H2_data$observed_condition %in% c(5), ] H3_data <- TF_num[TF_num$partial_discharge %in% c(3,4),] H4_data <- TF_num[! TF_num$partial_discharge %in% c(3,4),] H4_data <- H4_data[! H4_data$temperature_reading %in% c(3), ] H4_data <- H4_data[ H4_data$observed_condition %in% c(5), ] H5_data <- TF_num[! TF_num$partial_discharge %in% c(3,4),] H5_data <- H5_data[H5_data$temperature_reading %in% c(3), ] H5_data <- H5_data[H5_data$observed_condition %in% c(5), ] # multilinear regression on each part in the partition, to find the Weibull shape and scale parameters: counter <- 1 coeff_age <- matrix(0,5,10) shapes <- matrix(0,5,1) scales <- matrix(0,5,10) for (h in list(H1_data, H2_data, H3_data, H4_data, H5_data)) { # find multilinear model for expected lifetime: if(nrow(h) == 0) next lm_age <- lm(formula = age ~ utilisation_pct + placement + altitude_m + distance_from_coast_km + corrosion_category_index + partial_discharge + oil_acidity + temperature_reading + observed_condition, data = h) coeff_age[counter, ] <- lm_age$coefficients coeff_age[counter, is.na(coeff_age[counter, ])] <- 0 # find shape and scale parameters of Weibull distribution by comparing the sample variance with the model variance: C <- mean(lm_age$residuals^2)/mean(lm_age$fitted.values^2) shapes[counter] <- uniroot(function(x) {gamma(1 + 2/x)/(gamma(1 + 1/x))^2 - 1 - C}, c(1, 10))$root scales[counter, ] <- coeff_age[counter, ]/gamma(1 + 1 /shapes[counter]) counter <- counter + 1 } results <- data.frame(shapes = shapes, scales.intercept = scales[ , 1], scales = scales[ , 2:length(scales[1, ])]) return(results) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/weibull_model.R
.onAttach <- function(libname, pkgname) { packageStartupMessage("The CNAIM package is created by Utiligize. Please cite the CNAIM package as: Utiligize (2022). CNAIM: R package version 2.1.3, www.cnaim.io.") }
/scratch/gouwar.j/cran-all/cranData/CNAIM/R/zzz.R
## ----echo=F, message=F, class.source='highlight',comment=""------------------- library(CNAIM) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- pof <- pof_transformer_11_20kv( hv_transformer_type = "6.6/11kV Transformer (GM)", utilisation_pct = 55, placement = "Indoor", altitude_m = 75, distance_from_coast_km = 20, corrosion_category_index = 2, age = 25, partial_discharge = "Low", oil_acidity = 0.1, temperature_reading = "Normal", observed_condition = "Default", reliability_factor = "Default") sprintf("The probability of failure is %.2f%% per year", 100*pof) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- pof <- pof_transformer_11_20kv(age = 55) sprintf("The probability of failure is %.2f%% per year", 100*pof) ## ----echo=FALSE, message=F---------------------------------------------------- library(CNAIM) library(r2d3) library(jsonlite) library(dplyr) library(widgetframe) library(r2d3) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- financial_cof <- f_cof_transformer_11kv(kva = 750, type = "Type B") sprintf("The financial consequences of failure is GBP %.f", round(financial_cof)) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- safety_cof <- s_cof_swg_tf_ohl(type_risk = "Low", location_risk = "Medium", asset_type_scf = "6.6/11kV Transformer (GM)") sprintf("The safety consequences of failure is GBP %.f", round(safety_cof)) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- environmental_cof <- e_cof_tf(asset_type_tf = "6.6/11kV Transformer (GM)", rated_capacity = 750, prox_water = 95, bunded = "Yes") sprintf("The environmental consequences of failure is GBP %.f", round(environmental_cof)) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- network_cof <- n_cof_excl_ehv_132kv_tf(asset_type_ncf = "6.6/11kV Transformer (GM)", no_customers = 750, kva_per_customer = 1) sprintf("The network performance consequences of failure is GBP %.f", round(network_cof)) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- cof_transformer <- cof(financial_cof, safety_cof, environmental_cof, network_cof) sprintf("The consequences of failure is GBP %.f", cof_transformer) ## ----echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""---- cof_short_cut <- cof_transformer_11kv(kva = 750, type = "Type B", type_risk = "Low", location_risk = "Medium", prox_water = 95, bunded = "Yes", no_customers = 750, kva_per_customer = 1) all.equal(cof_transformer, cof_short_cut) ## ----------------------------------------------------------------------------- source('fns_monetary_risk.R') ## ----fake-calculation, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""---- # # Generate an empty 5x4 matrix # matrix_structure <- risk_matrix_structure(5,4,NA) # # Monetary risk for one asset # risk_coordinates <- risk_calculation(matrix_dimensions = matrix_structure, # id = "Transformer1", # pof = 0.08, # cof = 18232, # asset_type = "6.6/11kV Transformer (GM)") # risk_matrix_points_plot(matrix_structure, # dots_vector = risk_coordinates, # dot_radius = 4) ## ----fake-calculation-2, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""---- # # Generate an empty 5x4 matrix # risk_data_matrix <- risk_matrix_structure(5,4,NA) # risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) # risk_matrix_summary_plot(risk_data_matrix) ## ----fake-calculation-3, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""---- # # Generate an empty 5x4 matrix # risk_data_matrix <- risk_matrix_structure(5,4,NA) # risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) # risk_matrix_summary_plot(risk_data_matrix, # x_intervals = c(0.1,0.1,0.1,0.2,0.3), # y_intervals = c(0.75,0.75,1,1.5)) ## ----fake-calculation-4, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""---- # # Generate an empty 4x4 matrix # risk_data_matrix <- risk_matrix_structure(5,4,NA) # risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) # risk_matrix_summary_plot(risk_data_matrix)
/scratch/gouwar.j/cran-all/cranData/CNAIM/inst/doc/cnaim.R
--- title: "CNAIM" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{cnaim} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- # Introduction The green transition will require significant investment in utility infrastructure. Many countries have restrictive income caps or fixed tariffs that do not allow for investment to support the electrification of transport, heating and agricultural processes. Incentive-based revenue caps are the answer, and will likely be adopted in many countries over the next decade. This package allows regulators, data scientists and researchers to calculate and understand: 1) Asset lifetimes 2) Economic consequences of asset failures, both minor and major 3) Monetary risk 4) Probability of failure parameter estimates based on fault statistics ## Probability of failure In CNAIM, the probability of failure (PoF) is modelled as the first three terms of a Taylor Series expansion of an exponential function. $\begin{align*} PoF =& K \cdot e^{(C \cdot H)} \\=& K \cdot \sum_{n=1}^\infty \frac{(C \cdot H)^n}{n!} \\\approx& K \cdot \left[1 + (C \cdot H) + \frac{(C \cdot H)^2}{2!} + \frac{(C \cdot H)^3}{3!}\right] \end{align*}$ where \ $K$ scales the PoF to a failure rate that matches observed fault statistics \ $C$ describes the shape of the PoF curve \ $H$ is the health score based on observed and measured explanatory variables The definition of a functional failure can be divided into three classes of failure modes: * *Incipient - minor failure* * *Degraded - significant failure* * *Catastrophic - total failure* ```{r echo=F, message=F, class.source='highlight',comment=""} library(CNAIM) ``` ##### Example for a 6.6/11 kV transformer Assuming a transformer: - *has a utilization of 55%* - *is placed indoors* - *is sited at an altitude of 75m* - *has 20km to the coast* - *is sited in an area with a corrosion category index of 2* - *is 25 years old* - *has a low partial discharge* - *has an oil acidity of 0.1mgKOH/g* - *has a normal temperature reading* - *is in good observed condition* - *has a default reliability factor of 1* Then we can call the function as follows: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} pof <- pof_transformer_11_20kv( hv_transformer_type = "6.6/11kV Transformer (GM)", utilisation_pct = 55, placement = "Indoor", altitude_m = 75, distance_from_coast_km = 20, corrosion_category_index = 2, age = 25, partial_discharge = "Low", oil_acidity = 0.1, temperature_reading = "Normal", observed_condition = "Default", reliability_factor = "Default") sprintf("The probability of failure is %.2f%% per year", 100*pof) ``` The only mandetory input variable is age; the rest have defaults, so you can call the function like: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} pof <- pof_transformer_11_20kv(age = 55) sprintf("The probability of failure is %.2f%% per year", 100*pof) ``` ## Consequences of failure The CNAIM methodology's second key element is the consequence of a failure. When combined with probability of failure, the consequences of failure can be used to derive the monetary network risk. Consequence of failure calculations are based on the same failure modes as probability of failure. The consequences of failure can be divided into four: * *Financial consequences of failure* * *Safety consequences of failure* * *Environmental consequences of failure* * *Network performance consequences of failure* The sub-consequences have an associated asset specific reference cost of failure based on the British DNOs' experience and other objective sources. All reference costs are currently in 2012/2013 prices. The reference cost of failure for all sub-categories are scaled with respect to the specific conditions and locations of the individual asset. *Financial consequences of failure* considers cost associated with replacement and repairs that returns the asset to its initial condition before the incident. *Safety consequences of failure* considers the likelihood and the cost that a failure could be hazardous to a person or a worker including the likelihood that the failure could be fatal. The safety implications is taken from Electricity Safety, Quality and Continuity Regulations (ESQCR). *Environmental consequences of failure* considers the cost of a potential oil spill and mitigation of the extremely potent greenhouse gas, sulfur hexafluoride. *Network performance consequences of failure* considers the cost a failure imposes to the customers served by the by the asset and the number of interrupting minutes. ##### Example for a 6.6/11kV transformer Assuming a transformer: * *has a rated capacity of 750 kVA* * *has confined access i.e. assessed to be of a "Type B"* * *is exhibiting a low risk to the public* * *is exposed to a medium risk of trespassers* * *is located 95 meters from a stream* * *is serving 750 customers* * *has an average demand of 1 kVA per customer* ```{r echo=FALSE, message=F} library(CNAIM) library(r2d3) library(jsonlite) library(dplyr) library(widgetframe) library(r2d3) ``` ###### Financial consequences of failure The financial reference cost of failure for a 6.6/11kV transformer is £7,739, which is scaled by the rated capacity measured in kVA and the accessibility. The financial consequences of failure are found using: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} financial_cof <- f_cof_transformer_11kv(kva = 750, type = "Type B") sprintf("The financial consequences of failure is GBP %.f", round(financial_cof)) ``` ###### Safety consequences of failure The safety reference cost of failure for a 6.6/11kV transformer is £4,262, which is scaled by the location and the risk the transformer represents to the public. The function below is able to calculate the safety consequences of failure for switchgears, transformers and overhead lines: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} safety_cof <- s_cof_swg_tf_ohl(type_risk = "Low", location_risk = "Medium", asset_type_scf = "6.6/11kV Transformer (GM)") sprintf("The safety consequences of failure is GBP %.f", round(safety_cof)) ``` ###### Environmetal consequences of failure The environmental reference cost of failure for a 6.6/11kV transformer is £3,171. The environmental consequences of failure calculation considers proximity to water courses, the asset's rated capacity, and if the transformer is bunded or not. This function can calculate environmental consequences of failure for all types of transformers specified in CNAIM methodology: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} environmental_cof <- e_cof_tf(asset_type_tf = "6.6/11kV Transformer (GM)", rated_capacity = 750, prox_water = 95, bunded = "Yes") sprintf("The environmental consequences of failure is GBP %.f", round(environmental_cof)) ``` ###### Network performance consequences of failure The reference network performance cost of failure for a 6.6/11kV transformer is £4,862. This cost is scaled according to the number of customers connected to the transformer and kVA per customer. This function can calculate network consequences of failure for all assets with the exception EHV and 132kV asset: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} network_cof <- n_cof_excl_ehv_132kv_tf(asset_type_ncf = "6.6/11kV Transformer (GM)", no_customers = 750, kva_per_customer = 1) sprintf("The network performance consequences of failure is GBP %.f", round(network_cof)) ``` ###### Consequences of failure The overall consequences of failure in our example can found using: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} cof_transformer <- cof(financial_cof, safety_cof, environmental_cof, network_cof) sprintf("The consequences of failure is GBP %.f", cof_transformer) ``` The function adds the sub-consequences together to a total consequence of a failure. For the 6.6/11kV transformer described in this example, it is now possible to derive the monetary risk. A quick way to find the consequences of failure for the 6.6/11kV transformer in this example is: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} cof_short_cut <- cof_transformer_11kv(kva = 750, type = "Type B", type_risk = "Low", location_risk = "Medium", prox_water = 95, bunded = "Yes", no_customers = 750, kva_per_customer = 1) all.equal(cof_transformer, cof_short_cut) ``` ## Monetary risk ```{r} source('fns_monetary_risk.R') ``` Once probability of failure and consequences of failure have been calculated for each asset, monetary risk is calculated as: $Risk = PoF \cdot CoF$ Risk matrices for each asset class, along with cost-benefit analyses of interventions (reinvestment and maintenance) are submitted to the regulator, allowing utility and regulator to reach concensus on the right balance of cost and reliability. ##### Individual asset risk Given an asset with a probability of failure = 0.08\% per year and consequences of failure equal to £18,232, we can visualize and analyize which risk class this asset has with the following functions: ```{r fake-calculation, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 5x4 matrix matrix_structure <- risk_matrix_structure(5,4,NA) # Monetary risk for one asset risk_coordinates <- risk_calculation(matrix_dimensions = matrix_structure, id = "Transformer1", pof = 0.08, cof = 18232, asset_type = "6.6/11kV Transformer (GM)") risk_matrix_points_plot(matrix_structure, dots_vector = risk_coordinates, dot_radius = 4) ``` <img src="images/individual_asset_risk.svg" height="600" width="800" /> ##### Asset class risk Given a population of assets within the same asset class, we can visualize how monetary risk is distributed with the following example: ```{r fake-calculation-2, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 5x4 matrix risk_data_matrix <- risk_matrix_structure(5,4,NA) risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) risk_matrix_summary_plot(risk_data_matrix) ``` <img src="images/asset_class_risk.svg" height="600" width="800"/> ##### Non-linear bins Sometimes it is desirable to create the matrix with non-linear intervals, since each interval represents a bin of CoF and PoF, bins which typically increase in size as the CoF and health scores increase. The inputs `x_intervals` and `y_intervals` should match the x and y dimensions of the risk matrix data frame, but can contain any values, since these are internally normalised to 1. ```{r fake-calculation-3, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 5x4 matrix risk_data_matrix <- risk_matrix_structure(5,4,NA) risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) risk_matrix_summary_plot(risk_data_matrix, x_intervals = c(0.1,0.1,0.1,0.2,0.3), y_intervals = c(0.75,0.75,1,1.5)) ``` <img src="images/non_linear_bins.svg" height="600" width="800"/> ##### Matrices with different dimensions Although the CNAIM standard specifies a rigid 5x4 matrix, it might be desirable to implement different size risk matrices. The CNAIM R package offers this flexibility. For example, to make a 4x4 matrix: ```{r fake-calculation-4, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 4x4 matrix risk_data_matrix <- risk_matrix_structure(5,4,NA) risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) risk_matrix_summary_plot(risk_data_matrix) ``` <img src="images/different_dimensions.svg" height="600" width="800"/>
/scratch/gouwar.j/cran-all/cranData/CNAIM/inst/doc/cnaim.Rmd
--- title: "CNAIM" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{cnaim} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- # Introduction The green transition will require significant investment in utility infrastructure. Many countries have restrictive income caps or fixed tariffs that do not allow for investment to support the electrification of transport, heating and agricultural processes. Incentive-based revenue caps are the answer, and will likely be adopted in many countries over the next decade. This package allows regulators, data scientists and researchers to calculate and understand: 1) Asset lifetimes 2) Economic consequences of asset failures, both minor and major 3) Monetary risk 4) Probability of failure parameter estimates based on fault statistics ## Probability of failure In CNAIM, the probability of failure (PoF) is modelled as the first three terms of a Taylor Series expansion of an exponential function. $\begin{align*} PoF =& K \cdot e^{(C \cdot H)} \\=& K \cdot \sum_{n=1}^\infty \frac{(C \cdot H)^n}{n!} \\\approx& K \cdot \left[1 + (C \cdot H) + \frac{(C \cdot H)^2}{2!} + \frac{(C \cdot H)^3}{3!}\right] \end{align*}$ where \ $K$ scales the PoF to a failure rate that matches observed fault statistics \ $C$ describes the shape of the PoF curve \ $H$ is the health score based on observed and measured explanatory variables The definition of a functional failure can be divided into three classes of failure modes: * *Incipient - minor failure* * *Degraded - significant failure* * *Catastrophic - total failure* ```{r echo=F, message=F, class.source='highlight',comment=""} library(CNAIM) ``` ##### Example for a 6.6/11 kV transformer Assuming a transformer: - *has a utilization of 55%* - *is placed indoors* - *is sited at an altitude of 75m* - *has 20km to the coast* - *is sited in an area with a corrosion category index of 2* - *is 25 years old* - *has a low partial discharge* - *has an oil acidity of 0.1mgKOH/g* - *has a normal temperature reading* - *is in good observed condition* - *has a default reliability factor of 1* Then we can call the function as follows: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} pof <- pof_transformer_11_20kv( hv_transformer_type = "6.6/11kV Transformer (GM)", utilisation_pct = 55, placement = "Indoor", altitude_m = 75, distance_from_coast_km = 20, corrosion_category_index = 2, age = 25, partial_discharge = "Low", oil_acidity = 0.1, temperature_reading = "Normal", observed_condition = "Default", reliability_factor = "Default") sprintf("The probability of failure is %.2f%% per year", 100*pof) ``` The only mandetory input variable is age; the rest have defaults, so you can call the function like: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} pof <- pof_transformer_11_20kv(age = 55) sprintf("The probability of failure is %.2f%% per year", 100*pof) ``` ## Consequences of failure The CNAIM methodology's second key element is the consequence of a failure. When combined with probability of failure, the consequences of failure can be used to derive the monetary network risk. Consequence of failure calculations are based on the same failure modes as probability of failure. The consequences of failure can be divided into four: * *Financial consequences of failure* * *Safety consequences of failure* * *Environmental consequences of failure* * *Network performance consequences of failure* The sub-consequences have an associated asset specific reference cost of failure based on the British DNOs' experience and other objective sources. All reference costs are currently in 2012/2013 prices. The reference cost of failure for all sub-categories are scaled with respect to the specific conditions and locations of the individual asset. *Financial consequences of failure* considers cost associated with replacement and repairs that returns the asset to its initial condition before the incident. *Safety consequences of failure* considers the likelihood and the cost that a failure could be hazardous to a person or a worker including the likelihood that the failure could be fatal. The safety implications is taken from Electricity Safety, Quality and Continuity Regulations (ESQCR). *Environmental consequences of failure* considers the cost of a potential oil spill and mitigation of the extremely potent greenhouse gas, sulfur hexafluoride. *Network performance consequences of failure* considers the cost a failure imposes to the customers served by the by the asset and the number of interrupting minutes. ##### Example for a 6.6/11kV transformer Assuming a transformer: * *has a rated capacity of 750 kVA* * *has confined access i.e. assessed to be of a "Type B"* * *is exhibiting a low risk to the public* * *is exposed to a medium risk of trespassers* * *is located 95 meters from a stream* * *is serving 750 customers* * *has an average demand of 1 kVA per customer* ```{r echo=FALSE, message=F} library(CNAIM) library(r2d3) library(jsonlite) library(dplyr) library(widgetframe) library(r2d3) ``` ###### Financial consequences of failure The financial reference cost of failure for a 6.6/11kV transformer is £7,739, which is scaled by the rated capacity measured in kVA and the accessibility. The financial consequences of failure are found using: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} financial_cof <- f_cof_transformer_11kv(kva = 750, type = "Type B") sprintf("The financial consequences of failure is GBP %.f", round(financial_cof)) ``` ###### Safety consequences of failure The safety reference cost of failure for a 6.6/11kV transformer is £4,262, which is scaled by the location and the risk the transformer represents to the public. The function below is able to calculate the safety consequences of failure for switchgears, transformers and overhead lines: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} safety_cof <- s_cof_swg_tf_ohl(type_risk = "Low", location_risk = "Medium", asset_type_scf = "6.6/11kV Transformer (GM)") sprintf("The safety consequences of failure is GBP %.f", round(safety_cof)) ``` ###### Environmetal consequences of failure The environmental reference cost of failure for a 6.6/11kV transformer is £3,171. The environmental consequences of failure calculation considers proximity to water courses, the asset's rated capacity, and if the transformer is bunded or not. This function can calculate environmental consequences of failure for all types of transformers specified in CNAIM methodology: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} environmental_cof <- e_cof_tf(asset_type_tf = "6.6/11kV Transformer (GM)", rated_capacity = 750, prox_water = 95, bunded = "Yes") sprintf("The environmental consequences of failure is GBP %.f", round(environmental_cof)) ``` ###### Network performance consequences of failure The reference network performance cost of failure for a 6.6/11kV transformer is £4,862. This cost is scaled according to the number of customers connected to the transformer and kVA per customer. This function can calculate network consequences of failure for all assets with the exception EHV and 132kV asset: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} network_cof <- n_cof_excl_ehv_132kv_tf(asset_type_ncf = "6.6/11kV Transformer (GM)", no_customers = 750, kva_per_customer = 1) sprintf("The network performance consequences of failure is GBP %.f", round(network_cof)) ``` ###### Consequences of failure The overall consequences of failure in our example can found using: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} cof_transformer <- cof(financial_cof, safety_cof, environmental_cof, network_cof) sprintf("The consequences of failure is GBP %.f", cof_transformer) ``` The function adds the sub-consequences together to a total consequence of a failure. For the 6.6/11kV transformer described in this example, it is now possible to derive the monetary risk. A quick way to find the consequences of failure for the 6.6/11kV transformer in this example is: ```{r echo=TRUE, message=FALSE, warning=FALSE, class.source='highlight',comment=""} cof_short_cut <- cof_transformer_11kv(kva = 750, type = "Type B", type_risk = "Low", location_risk = "Medium", prox_water = 95, bunded = "Yes", no_customers = 750, kva_per_customer = 1) all.equal(cof_transformer, cof_short_cut) ``` ## Monetary risk ```{r} source('fns_monetary_risk.R') ``` Once probability of failure and consequences of failure have been calculated for each asset, monetary risk is calculated as: $Risk = PoF \cdot CoF$ Risk matrices for each asset class, along with cost-benefit analyses of interventions (reinvestment and maintenance) are submitted to the regulator, allowing utility and regulator to reach concensus on the right balance of cost and reliability. ##### Individual asset risk Given an asset with a probability of failure = 0.08\% per year and consequences of failure equal to £18,232, we can visualize and analyize which risk class this asset has with the following functions: ```{r fake-calculation, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 5x4 matrix matrix_structure <- risk_matrix_structure(5,4,NA) # Monetary risk for one asset risk_coordinates <- risk_calculation(matrix_dimensions = matrix_structure, id = "Transformer1", pof = 0.08, cof = 18232, asset_type = "6.6/11kV Transformer (GM)") risk_matrix_points_plot(matrix_structure, dots_vector = risk_coordinates, dot_radius = 4) ``` <img src="images/individual_asset_risk.svg" height="600" width="800" /> ##### Asset class risk Given a population of assets within the same asset class, we can visualize how monetary risk is distributed with the following example: ```{r fake-calculation-2, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 5x4 matrix risk_data_matrix <- risk_matrix_structure(5,4,NA) risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) risk_matrix_summary_plot(risk_data_matrix) ``` <img src="images/asset_class_risk.svg" height="600" width="800"/> ##### Non-linear bins Sometimes it is desirable to create the matrix with non-linear intervals, since each interval represents a bin of CoF and PoF, bins which typically increase in size as the CoF and health scores increase. The inputs `x_intervals` and `y_intervals` should match the x and y dimensions of the risk matrix data frame, but can contain any values, since these are internally normalised to 1. ```{r fake-calculation-3, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 5x4 matrix risk_data_matrix <- risk_matrix_structure(5,4,NA) risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) risk_matrix_summary_plot(risk_data_matrix, x_intervals = c(0.1,0.1,0.1,0.2,0.3), y_intervals = c(0.75,0.75,1,1.5)) ``` <img src="images/non_linear_bins.svg" height="600" width="800"/> ##### Matrices with different dimensions Although the CNAIM standard specifies a rigid 5x4 matrix, it might be desirable to implement different size risk matrices. The CNAIM R package offers this flexibility. For example, to make a 4x4 matrix: ```{r fake-calculation-4, echo=TRUE, message=FALSE, warning=FALSE, eval=F, class.source='highlight',comment=""} # Generate an empty 4x4 matrix risk_data_matrix <- risk_matrix_structure(5,4,NA) risk_data_matrix$value <- sample(1:30,size=nrow(matrix_structure),replace = T) risk_matrix_summary_plot(risk_data_matrix) ``` <img src="images/different_dimensions.svg" height="600" width="800"/>
/scratch/gouwar.j/cran-all/cranData/CNAIM/vignettes/cnaim.Rmd
matrix_adjusted_circles = function(risk_data_matrix, dots_vector, dot_radius){ risk_data_matrix <- risk_data_matrix %>% ungroup() %>% mutate(id = row_number()) dot_radius = tibble::enframe(dot_radius) %>% rename(id = name, dot_radius = value) risk_data_matrix <- risk_data_matrix %>% full_join(dots_vector ) %>% mutate(x = ifelse(is.na(x), 'na',x)) %>% mutate(y = ifelse(is.na(y), 'na',y)) %>% mutate(value = ifelse(is.na(value), 'na',value)) %>% mutate(point_x = ifelse(is.na(point_x), 'na',point_x)) %>% mutate(point_y = ifelse(is.na(point_y), 'na',point_y)) %>% left_join(dot_radius) %>% mutate(dot_radius = ifelse(is.na(dot_radius), 'na',dot_radius)) risk_data_matrix } matrix_adjusted_intervals = function(risk_data_matrix, x_intervals, y_intervals){ risk_data_matrix <- risk_data_matrix %>% ungroup() %>% mutate(id = row_number()) x_intervals = tibble::enframe(x_intervals) %>% rename(id = name, x_intervals = value) y_intervals = tibble::enframe(y_intervals) %>% rename(id = name, y_intervals = value) risk_data_matrix <- risk_data_matrix %>% full_join(x_intervals ) %>% mutate(x_intervals = ifelse(is.na(x_intervals), 'na',x_intervals)) %>% full_join(y_intervals ) %>% mutate(y_intervals = ifelse(is.na(y_intervals), 'na',y_intervals)) risk_data_matrix } matrix_combined = function(risk_data_matrix, dots_vector, dot_radius, x_intervals, y_intervals){ risk_data_matrix <- risk_data_matrix %>% ungroup() %>% mutate(id = row_number()) dot_radius = tibble::enframe(dot_radius) %>% rename(id = name, dot_radius = value) x_intervals = tibble::enframe(x_intervals) %>% rename(id = name, x_intervals = value) y_intervals = tibble::enframe(y_intervals) %>% rename(id = name, y_intervals = value) risk_data_matrix <- risk_data_matrix %>% full_join(dots_vector ) %>% mutate(x = ifelse(is.na(x), 'na',x)) %>% mutate(y = ifelse(is.na(y), 'na',y)) %>% mutate(value = ifelse(is.na(value), 'na',value)) %>% mutate(point_x = ifelse(is.na(point_x), 'na',point_x)) %>% mutate(point_y = ifelse(is.na(point_y), 'na',point_y)) %>% left_join(dot_radius) %>% mutate(dot_radius = ifelse(is.na(dot_radius), 'na',dot_radius)) %>% group_by(x) %>% mutate(sums_x = sum(value)) %>% ungroup() %>% mutate(sums_x = ifelse(y != 1, 'na',sums_x )) %>% group_by(y) %>% mutate(sums_y = sum(value)) %>% ungroup() %>% mutate(sums_y = ifelse(x != 1, 'na',sums_y )) %>% full_join(x_intervals ) %>% mutate(x_intervals = ifelse(is.na(x_intervals), 'na',x_intervals)) %>% full_join(y_intervals ) %>% mutate(y_intervals = ifelse(is.na(y_intervals), 'na',y_intervals)) return(risk_data_matrix) }
/scratch/gouwar.j/cran-all/cranData/CNAIM/vignettes/fns_monetary_risk.R
#' @title Get age information from ID number #' #' @description #' Get age information from ID number, to the day. #' #' @param id A vector of ID numbers. #' #' @return Age vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' age(id) #' #' @export #------------------------------------------------------------------------------# age = function(id) { cnid_info(id)$age } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/age.R
#' @title Get age information from ID number #' #' @description #' Get age information from ID number, only by year, not the specific date. #' #' @param id A vector of ID numbers. #' #' @return Age vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' age_by_year(id) #' #' @export #------------------------------------------------------------------------------# age_by_year = function(id) { cnid_info(id)$age_by_year } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/age_by_year.R
#' @title Get date of birth information from ID number #' #' @description #' Get date of birth information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Date of birth vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' birth_date(id) #' #' @export #------------------------------------------------------------------------------# birth_date = function(id) { cnid_info(id)$birth_date } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/birth_date.R
#' @title Get day of birth information from ID number #' #' @description #' Get day of birth information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Day of birth vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' birth_day(id) #' #' @export #------------------------------------------------------------------------------# birth_day = function(id) { cnid_info(id)$birth_day } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/birth_day.R
#' @title Get month of birth information from ID number #' #' @description #' Get month of birth information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Month of birth vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' birth_month(id) #' #' @export #------------------------------------------------------------------------------# birth_month = function(id) { cnid_info(id)$birth_month } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/birth_month.R
#' @title Get year of birth information from ID number #' #' @description #' Get year of birth information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Year of birth vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' birth_year(id) #' #' @export #------------------------------------------------------------------------------# birth_year = function(id) { cnid_info(id)$birth_year } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/birth_year.R
#' @title Check the ID number for logical errors #' #' @description #' Check the ID number for logical errors. #' #' @param id A vector of ID numbers. #' #' @return A vector of TRUE or FALSE. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' check_id(id) #' #' @export #------------------------------------------------------------------------------# check_id = function(id) { cnid_info(id)$check_id } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/check_id.R
#' @title Get full information from ID number #' #' @description #' Get full information from ID number. #' #' @param id A vector of ID numbers. #' #' @return A list about date of birth, age, gender, etc. #' obtained from ID number. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' cnid_info(id) #' #' @export #------------------------------------------------------------------------------# cnid_info = function(id) { # Current date current_year = as.integer(format(Sys.Date(), "%Y")) current_month = as.integer(format(Sys.Date(), "%m")) current_day = as.integer(format(Sys.Date(), "%d")) # Extract the basic information of birth, gender and region birth_year = character(length(id)) birth_month = character(length(id)) birth_day = character(length(id)) gender_code = character(length(id)) region_code = character(length(id)) for (i in 1:length(id)) { if (nchar(id[i]) == 15) { # 15 digit ID number birth_year[i] = paste0("19", substr(id[i], 7, 8)) birth_month[i] = substr(id[i], 9, 10) birth_day[i] = substr(id[i], 11, 12) gender_code[i] = as.integer(substr(id[i], 15, 15)) region_code[i] = as.integer(substr(id[i], 1, 6)) } else if ( nchar(id[i]) == 18 & (substr(id[i], 18, 18) %in% as.character(c(0:9, "X"))) ) { # 18 digit ID number birth_year[i] = substr(id[i], 7, 10) birth_month[i] = substr(id[i], 11, 12) birth_day[i] = substr(id[i], 13, 14) gender_code[i] = as.integer(substr(id[i], 17, 17)) region_code[i] = as.integer(substr(id[i], 1, 6)) } else { birth_year[i] = NA birth_month[i] = NA birth_day[i] = NA gender_code[i] = NA region_code[i] = NA } } for (i in 1:length(birth_year)) { y = birth_year[i] if (grepl("^\\d+$", y) == TRUE) { if (as.integer(y) > current_year) { birth_year[i] = NA } else { birth_year[i] = birth_year[i] } } else { birth_year[i] = NA } } birth_year = as.integer(birth_year) for (i in 1:length(birth_month)) { m = birth_month[i] if (grepl("^\\d+$", m) == TRUE) { if (as.integer(m) < 1 | as.integer(m) > 12) { birth_month[i] = NA } else { birth_month[i] = birth_month[i] } } else { birth_month[i] = NA } } birth_month = as.integer(birth_month) for (i in 1:length(birth_day)) { d = birth_day[i] if (grepl("^\\d+$", d) == TRUE) { if (as.integer(d) < 1 | as.integer(d) > 31) { birth_day[i] = NA } else { birth_day[i] = birth_day[i] } } else { birth_day[i] = NA } } birth_day = as.integer(birth_day) gender_code = as.integer(gender_code) region_code = as.integer(region_code) # Parse the birth date birth_date = seq( as.Date("1900/1/1"), by = "month", length.out = length(id) ) for (i in 1:length(id)) { y = birth_year[i] m = birth_month[i] d = birth_day[i] if (is.na(y) | is.na(m) | is.na(d)) { birth_date[i] = NA } else { if (d <= mdays(m, y)) { birth_date[i] = as.Date( paste(y, m, d, sep = "-") ) } else { birth_date[i] = NA } } } # Accurate age age = integer(length(id)) for (i in 1:length(id)) { y = birth_year[i] m = birth_month[i] d = birth_day[i] bd = birth_date[i] if (is.na(bd)) { age[i] = NA } else { if ( current_month < m | (current_month == m & current_day < d) ) { age[i] = current_year - y - 1 } else { age[i] = current_year - y } } } # Age by year age_by_year = integer(length(id)) for (i in 1:length(id)) { y = birth_year[i] if (is.na(y)) { age_by_year[i] = NA } else { age_by_year[i] = current_year - y } } # Parse gender gender = ifelse( gender_code %% 2 == 0, "\u5973", "\u7537" ) # Parse region region = character(length = length(id)) for (i in 1:length(id)) { rc = region_code[i] if (is.na(rc)) { region[i] = NA } else { if (rc %in% region_code_base$code) { region[i] = region_code_base$region[ region_code_base$code == rc ] } else { region[i] = NA } } } # Parse the Chinese zodiac zodiacs <- c( "\u9f20", "\u725b", "\u864e", "\u5154", "\u9f99", "\u86c7", "\u9a6c", "\u7f8a", "\u7334", "\u9e21", "\u72d7", "\u732a" ) zodiac = character(length = length(id)) for (i in 1:length(id)) { y = birth_year[i] if (is.na(y)) { zodiac[i] = NA } else { zodiac[i] = zodiacs[(y - 1900) %% 12 + 1] } } # Parse constellation get_cstl = function(birth_month, birth_day) { cstls = c( "\u6c34\u74f6\u5ea7", "\u53cc\u9c7c\u5ea7", "\u767d\u7f8a\u5ea7", "\u91d1\u725b\u5ea7", "\u53cc\u5b50\u5ea7", "\u5de8\u87f9\u5ea7", "\u72ee\u5b50\u5ea7", "\u5904\u5973\u5ea7", "\u5929\u79e4\u5ea7", "\u5929\u874e\u5ea7", "\u5c04\u624b\u5ea7", "\u6469\u7faf\u5ea7" ) xinzuo = character(length = length(birth_month)) for (i in 1:length(birth_month)) { y = birth_year[i] m = birth_month[i] d = birth_day[i] bd = birth_date[i] if (is.na(m) | is.na(d)) { xinzuo[i] = NA } else if ( is.na(y) == FALSE & is.na(m) == FALSE & is.na(d) == FALSE & is.na(bd) == TRUE ) { xinzuo[i] = NA } else if ((m == 1 & d >= 20) | (m == 2 & d <= 18)) { xinzuo[i] = cstls[1] # shuiping(0120-0218) } else if ((m == 2 & d >= 19) | (m == 3 & d <= 20)) { xinzuo[i] = cstls[2] # shuangyu(0219-0320) } else if ((m == 3 & d >= 21) | (m == 4 & d <= 19)) { xinzuo[i] = cstls[3] # baiyang(0321-0419) } else if ((m == 4 & d >= 20) | (m == 5 & d <= 20)) { xinzuo[i] = cstls[4] # jinniu(0420-0520) } else if ((m == 5 & d >= 21) | (m == 6 & d <= 20)) { xinzuo[i] = cstls[5] # shuangzi(0521-0620) } else if ((m == 6 & d >= 21) | (m == 7 & d <= 22)) { xinzuo[i] = cstls[6] # juxie(0621-0722) } else if ((m == 7 & d >= 23) | (m == 8 & d <= 22)) { xinzuo[i] = cstls[7] # shizi(0723-0822) } else if ((m == 8 & d >= 23) | (m == 9 & d <= 22)) { xinzuo[i] = cstls[8] # chunv(0823-0922) } else if ((m == 9 & d >= 23) | (m == 10 & d <= 22)) { xinzuo[i] = cstls[9] # tiancheng(0923-1022) } else if ((m == 10 & d >= 23) | (m == 11 & d <= 21)) { xinzuo[i] = cstls[10] # tianxie(1023-1121) } else if ((m == 11 & d >= 22) | (m == 12 & d <= 21)) { xinzuo[i] = cstls[11] # sheshou(1122-1221) } else if ((m == 12 & d >= 22) | (m == 1 & d <= 19)) { xinzuo[i] = cstls[12] # mojie(1222-0119) } else { xinzuo[i] = NA } } return(xinzuo) } cstl = get_cstl(birth_month, birth_day) # Check the ID number for logical problems key = data.frame( region, birth_year, birth_month, birth_day, birth_date, gender ) check_id = logical(length = length(id)) for (i in 1:length(id)) { if (any(is.na(key[i, ]))) { check_id[i] = FALSE } else { check_id[i] = TRUE } } # Generate result list result = list( check_id = check_id, birth_year = birth_year, birth_month = birth_month, birth_day = birth_day, birth_date = birth_date, age = age, age_by_year = age_by_year, gender = gender, region = region, zodiac = zodiac, cstl = cstl ) # prompt if (all(nchar(id) %in% c(15, 18)) == FALSE) { warning("There are cases where the ID number is not 15 or 18 digits.") } if (any(check_id == FALSE)) { warning("There are cases where the ID number has a logical error.") } # Return final result return(result) } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/cnid_info.R
#' @title Get constellation information from ID number #' #' @description #' Get constellation information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Constellation vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' cstl(id) #' #' @export #------------------------------------------------------------------------------# cstl = function(id) { cnid_info(id)$cstl } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/cstl.R
#' @title Get gender information from ID number #' #' @description #' Get gender information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Gender vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' gender(id) #' #' @export #------------------------------------------------------------------------------# gender = function(id) { cnid_info(id)$gender } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/gender.R
#' @title Calculate the number of days in a specified year and month #' #' @description #' Calculate the number of days in a specified year and month. #' #' @param month A given month, such as 2. #' #' @param year A given year, the default is current year. #' #' @return Days in a specified year and month. #' #' @examples #' mdays(2, 2022) #' #' @export #------------------------------------------------------------------------------# mdays = function( month, year = as.integer(format(Sys.Date(), "%Y")) ) { if (is.na(as.numeric(month))) { stop("month must be numeric value") } if (is.na(as.numeric(year))) { stop("year must be numeric value") } month = as.integer(month) year = as.integer(year) if (month < 1 || month > 12) { stop("The month must be between 1 and 12") } days_in_month = integer(12) days_in_month[c(1, 3, 5, 7, 8, 10, 12)] = 31 days_in_month[c(4, 6, 9, 11)] = 30 days_in_month[2] = 28 + ( (year %% 4 == 0 && year %% 100 != 0) || (year %% 400 == 0) ) return(days_in_month[month]) } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/mdays.R
#' @title Get region information from ID number #' #' @description #' Get region information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Region vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' region(id) #' #' @export #------------------------------------------------------------------------------# region = function(id) { cnid_info(id)$region } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/region.R
#' @title Calculate the number of days in a specified year #' #' @description #' Calculate the number of days in a specified year. #' #' @param year A given year, the default is current year. #' #' @return Days in a specified year. #' #' @examples #' ydays(2022) #' #' @export #------------------------------------------------------------------------------# ydays = function( year = as.integer(format(Sys.Date(), "%Y")) ) { if (is.na(as.numeric(year))) { stop("year must be numeric value") } year = as.integer(year) days_in_year = 365 + ( (year %% 4 == 0 && year %% 100 != 0) || (year %% 400 == 0) ) return(days_in_year) } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/ydays.R
#' @title Get zodiac information from ID number #' #' @description #' Get zodiac information from ID number. #' #' @param id A vector of ID numbers. #' #' @return Zodiac vector obtained from ID numbers. #' #' @examples #' id = c( #' "652801197305161555", #' "130206202202291545", #' "110101841125178" #' ) #' zodiac(id) #' #' @export #------------------------------------------------------------------------------# zodiac = function(id) { cnid_info(id)$zodiac } #------------------------------------------------------------------------------#
/scratch/gouwar.j/cran-all/cranData/CNID/R/zodiac.R
cnlt.reg <- function (x, f, P = 50, returnall = FALSE, nkeep=2, ...) { n <- length(x) vec <- matrix(0, P, n - nkeep) deni <- df <- NULL aveghat <- matrix(0,1,n) for (i in 1:P) { cat(i, "...\n") v <- sample(1:n, (n - nkeep), FALSE) vec[i, ] <- v deni <- denoisepermC(x, f, nkeep=nkeep,mod = v, returnall = FALSE, ...) aveghat <- aveghat + matrix(deni,nrow=1) } aveghat <- aveghat/P if (returnall) { return(list(vec = vec, aveghat = aveghat)) } else { return(aveghat) } }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/cnlt.reg.R
denoisepermC <-function (x, f, returnall = FALSE, sdtype="adlift", verbose = FALSE, ...) { sdvec<-rep(1,length(x)) newcoeff <- NULL ndetlist <- list() tclist <- NULL out <- fwtnppermC(x, f, ...) W<-out$W nfilt<- 2 # symmetric neighbours for the moment lr <- out$lengthsremove rem <- out$removelist al <- artlev(lr, rem) levno <- length(al) # Gpre = W %*% t(Conj(W)) Gpre = tcrossprod(W,Conj(W)) if(sdtype!="adlift"){ indsd<-sqrt(diag(Gpre)) } else{ indsd<-sqrt(diag(tcrossprod(Re(W)))) } norcoeff <- out$coeffv/indsd ndetlist <- norcoeff[al[[1]]] if(sdtype!="adlift"){ sdsq <- mean(c(mad(Re(ndetlist)), mad(Im(ndetlist))))^2 } else{ sdsq <- mad(Re(ndetlist))^2 } # C = sdsq * W%*%t(W) # should be no conjugation involved here C = sdsq * tcrossprod(W) # should be no conjugation involved here G = sdsq * Gpre P = Conj(G) - t(Conj(C))%*%solve(G)%*%C Sigma<-array(0,dim=c(2,2,length(norcoeff))) # Vxx Vyy Vxy Vyx Sigma[1,1,] <- diag(Re(G+C)/2) # gets jk, jk value Sigma[2,2,] <- diag(Re(G-C)/2) Sigma[1,2,] <- -diag(Im(G-C)/2) Sigma[2,1,] <- diag(Im(G+C)/2) ll<-mthreshC(out$coeffv,Sigma,rem,out$pointsin,ali=al, verbose = verbose) newcoeff<-ll$coeffvt fhat<-NULL out$coeffv<-newcoeff fhat<-solve(Re(W))%*%Re(newcoeff) if (returnall) { return(list(fhat = fhat, w = out$W, indsd = indsd, al = al, sd = sd)) } else { return(fhat) } }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/denoisepermC.R
denoisepermCh <-function (x, f, returnall = FALSE, verbose = FALSE, ...) { sdvec<-rep(1,length(x)) newcoeff <- NULL ndetlist <- list() tclist <- NULL out <- fwtnppermC(x, f, ...) W<-out$W nfilt<- 2 # symmetric neighbours for the moment lr <- out$lengthsremove rem <- out$removelist al <- artlev(lr, rem) levno <- length(al) Gpre = W %*% t(Conj(W)) # do the real transform heterosced. variance estimation. This will overrule any computation above n<-length(x) out1 <- fwtnpperm(x, f, do.W = FALSE, varonly = FALSE,mod=rem, ...) po1 <- out1$pointsin nonorcoeff1 <- out1$coeff lr1 <- out1$lengthsremove # although these should be the same as the complex one above al1 <- artlev(lr1, rem) # levno1 <- length(al1) detail <- y <- matrix(0, 1, n - length(po1)) y <- x[setdiff(1:n, po1)] # sort rem for speed? detail <- nonorcoeff1[setdiff(1:n, po1)] h <- heterovar(y, detail, al1) sdvech1 <- h$varvec1 sdh1 <- NULL sdh1[setdiff(1:n, po1)] <- sdvech1 sdh1[po1] <- NA sdsq<-sdh1^2 # now proceed as before... # C = sdsq * W%*%t(W) # should be no conjugation involved here C = sdsq * tcrossprod(W) # should be no conjugation involved here G = sdsq * Gpre # P = Conj(G) - t(Conj(C))%*%solve(G)%*%C Sigma<-array(0,dim=c(2,2,length(nonorcoeff1))) # Vxx Vyy Vxy Vyx Sigma[1,1,] <- diag(Re(G+C)/2) # gets jk, jk value Sigma[2,2,] <- diag(Re(G-C)/2) Sigma[1,2,] <- -diag(Im(G-C)/2) Sigma[2,1,] <- diag(Im(G+C)/2) ll<-mthreshC(out$coeffv, Sigma, rem, out$pointsin, ali=al, verbose = verbose) newcoeff<-ll$coeffvt fhat<-NULL out$coeffv<-newcoeff fhat<-solve(Re(W))%*%Re(newcoeff) if (returnall) { return(list(fhat = fhat, w = out$W, al = al, sd = sqrt(sdsq))) } else { return(fhat) } }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/denoisepermCh.R
fwtnppermC <- function (x, f, LocalPred = LinearPred, neighbours = 1, intercept = TRUE, closest = FALSE, nkeep = 2, mod = sample(1:length(x), (length(x) - nkeep), FALSE)) { X <- x I <- intervals(X, "reflect") lengths <- lengthintervals(X, I, type = "midpoints", neighbours, closest) X <- as.row(X) f <- as.row(f) nkeep <- max(nkeep, 1) n <- length(X) removelist <- NULL lengthsremove <- NULL neighbrs <- list() gamlist <- list() alphalist <- list() schemehist <- NULL interhist <- NULL clolist <- NULL pointsin <- matrix(1:n, 1, n) pointsin <- pointsin[order(X)] Ialpha <- NULL # alterations for multifilter lifting. This assumes nfilt = 2* neigbours # for a (2*neighbours+1)-tap filter length. This is (for the moment) for # closest = FALSE. The routine should also be for a fixed trajectory so # that the order of removal is the same for all filters. # EDIT: for the Hamilton et al. (2018), nfilt = 2, so changed to be fixed below. # nfilt <- 2*neighbours nfilt <- 2 ri<- neighbours + 1 # index of remove in filter coeff <- matrix(f,nrow = n, ncol = nfilt) # should be f rep'd by col matno <- n - nkeep W <- diag(n) W <-array(rep(W,times=nfilt),c(n,n,nfilt)) filtlist<-vector("list",matno) for (j in 1:matno) { remove <- mod[j] removelist[j] <- remove out <- getnbrs(X, remove, pointsin, neighbours, closest) nbrs <- out$n index <- out$index ds <- abs(X[nbrs] - X[remove]) irregdeg <- max(ds)/min(ds) res <- LocalPred(pointsin, X, coeff, nbrs, remove, intercept, neighbours) if (length(res) == 2) { l <- res[[1]] clolist[j] <- res[[2]][[1]] nbrs <- res[[2]][[2]] index <- res[[2]][[3]] } else { l <- res } neighbrs[[j]] <- nbrs weights <- l[[1]] pred <- l[[2]] if (length(l) == 3) { scheme <- NULL int <- NULL details <- NULL } else { scheme <- l[[5]] int <- l[[4]] details <- l[[6]] } ## here come the modifications: ## note that the original weight vector may change a little # temporary fix to avoid edge prediction problems: weightsa<-append(weights,1,after=neighbours) # adds unit weight into middle # just in case, do this the append way: nbrsa<-append(nbrs,remove,after=neighbours) # adds remove into middle # update all coeff vectors by first updated c [replace] (see below) # and apply filters to all coeff matrix m<-matrix(coeff[nbrs,],nrow=length(nbrs)) tmpca<-insertRow(m,ri, v = coeff[remove,]) filtmat<-orthpredfilters(weightsa) filtlist[[j]]<-filtmat # does all filters at once coeff[remove,] <- colSums(filtmat * tmpca) # update accordingly: see above # new bit should be fine now too: use first filter (already removed invalid one above) if(length(nbrs)>1){ w<- -filtmat[-ri,1] } else{ w<-1 # single weight } l1 <- PointsUpdate(X, coeff[,1], nbrs, index, remove, pointsin, w, lengths) coeff[nbrs,] <- l1$coeff[nbrs] lengths <- l1$lengths r <- l1$r weights <- l1$weights N <- l1$N alpha <- l1$alpha # now update the lifting matrix Wtmp<-array(sapply(1:nfilt, function(i) W[nbrsa,,i]*filtmat[,i]),dim=c(length(nbrsa),n,nfilt)) W[remove,, ] <- apply(Wtmp, c(2,3), sum ) # should be n x nfilt W[nbrs,,] <- W[nbrs,,1] + matrix(alpha) %*% W[remove,,1] lengthsremove[j] <- lengths[r] Ialpha[j]<-irregdeg gamlist[[j]] <- weights alphalist[[j]] <- alpha schemehist[j] <- scheme interhist[j] <- int lengths <- lengths[setdiff(1:length(pointsin), r)] pointsin <- setdiff(pointsin, remove) } coeffv<-NULL coeffv<-complex(real=coeff[,1],imaginary=coeff[,2]) # set the scaling coeffs to be the ones from only the first transform (real) # and do the same for the lifting matrix W<-matrix(complex(real=W[,,1],imaginary=W[,,2]),nrow=n,ncol=n) N <- length(pointsin) return(list(coeff = coeff, lengthsremove = lengthsremove, pointsin = pointsin, removelist = removelist, gamlist = filtlist, alphalist = alphalist, W = W, reo = match(1:n,c(pointsin,removelist)), coeffv=coeffv, Ialpha = Ialpha)) }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/fwtnppermC.R
mthreshC <-function (coeffv, Sigma, rl ,po, ali, verbose = FALSE) { n<-length(coeffv) nsteps<-length(rl) # number of lifting steps nkeep <-length(po) # number not lifted nfilt<-2 coeffvt<-cbind(Re(coeffv),Im(coeffv)) chisq<-rep(NA,nsteps) onenbrcheck<-function(m){abs(det(m)) < 1e-7} nlev<-length(ali) for (i in 1:nlev) { rows<-ali[[i]] nj<-length(rows) chithresh <- 2 * log(nj) + (nfilt -2) * log(log(nj)) cat("chi^2 threshold is:",chithresh,"\n") for(j in 1:nj){ rem<-rows[j] dr<-matrix(coeffvt[rem,],ncol=1) # now check for singularity: m <- Sigma[,,rem] onenbr<-onenbrcheck(m) if(onenbr){ # "ignore correlation m[2,1]<-m[1,2]<-0 } sigjinv<-solve(m) chisq[i]<-t(dr) %*% sigjinv %*% dr # should be a 1x1 value to test if(verbose){ cat("chisq stat is:",chisq[i],"\n") } # now threshold, a la Barber and Nason 04 P.9 # shrink according to the modulus of the vector if (chisq[i] > 0){ shrink <- (max(chisq[i] - chithresh, 0))/chisq[i] } else{ shrink <- 0 } coeffvt[rem,] <- t(dr) * shrink } } l<-list() l$chi<-chisq l$coeffvt<-complex(real=coeffvt[,1],imaginary=coeffvt[,2]) return(l) }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/mthreshC.R
orthpredfilters<-function(filter = c(0.5, 1, 0.5)){ n<-length(filter) ri<-(n+1)/2 # only works for odd length filter A<-matrix (NA,n,n) if(n==2){ # nbr , remove A<-matrix(c(-1,1,1,1),2,2) } if (n==3){ A[,1]<-c(1,-1,1) A[,2]<-filter A[,3]<-c(-(1+filter[3])/(filter[1]+1),-(filter[3]-filter[1])/(filter[1]+1),1) } if(n==2){ QA<-A } else{ # orthogonal and equal norms (filter 1) nn<-colSums(A^2) n1<-nn[2] # should be the same as sum(filter^2) QA<-A QA[,3:ncol(QA)]<-sqrt(n1)*QA[,3:ncol(QA)]/rep(sqrt(nn[3:ncol(QA)]),each=nrow(QA)) # remove first column and minus QA<-QA[,-1] QA<- -QA QA[ri,]<--QA[ri,] } return(QA) }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/orthpredfilters.R
## this is the equivalent of .First.lib (for packages with a namespace) ## note that it is general, so the name of the package etc doesn't need ## to be specified (just say whatever you want in the prints though). .onAttach <-function(lib,pkg) { ver <- read.dcf(file.path(lib, pkg, "DESCRIPTION"), "Version") ver <- as.character(ver) curdate <- read.dcf(file.path(lib, pkg, "DESCRIPTION"), "Date") curdate <- as.character(curdate) # Welcome message (MAN): packageStartupMessage(paste( "\n", "******************************************************************************\n", " CNLTreg: Complex-Valued Wavelet Lifting for Signal Denoising \n\n", " --- Written by Matt Nunes and Marina Knight ---\n", " --- Contributions from Jean Sanderson and Piotr Fryzlewicz ---\n", " Current package version: ",ver," (",curdate,") \n\n", "\n", "******************************************************************************\n","\n") ) }
/scratch/gouwar.j/cran-all/cranData/CNLTreg/R/zzz.R
cnlt.biv <-function (x1, x2 = NULL, f1, f2, P = 100, nkeep = 2, use.same.trajectories = FALSE, verbose = TRUE, ...) { det1<-det2<-lre1<-lre2<-lreA1<-lreA2<-list() if(is.null(x2)|identical(x1,x2)){ # same grids same.grid<-TRUE x2 <- x1 # make sure in the case of no x2 input # use same trajectory set use.same.trajectories <- TRUE } else{ same.grid<-FALSE } if(use.same.trajectories){ if (verbose) { pb <- txtProgressBar(min = 0, max = 100, style = 3) } for (i in 1:P) { if (verbose) { setTxtProgressBar(pb, 100 * i/P) } veci <- sample(1:length(x1), length(x1) - nkeep, FALSE) ff1 <- fwtnppermC(x1, f1, nkeep = nkeep, mod = veci, ...) ff2 <- fwtnppermC(x2, f2, nkeep = nkeep, mod = veci, ...) det1[veci] <- mapply(c, det1[veci], as.list(ff1$coeffv[as.vector(veci)])) det2[veci] <- mapply(c, det2[veci], as.list(ff2$coeffv[as.vector(veci)])) lre1[veci] <- mapply(c, lre1[veci], as.list(ff1$lengthsremove)) lre2[veci] <- mapply(c, lre2[veci], as.list(ff2$lengthsremove)) lreA1[veci] <- mapply(c, lreA1[veci], as.list(ff1$Ialpha)) lreA2[veci] <- mapply(c, lreA2[veci], as.list(ff2$Ialpha)) } cat("\n") } else{ # do runs independently tmp<-cnlt.univ(x1, f1, P = P, nkeep = nkeep, verbose = verbose, ...) tmp2<-cnlt.univ(x2, f2, P = P, nkeep = nkeep, verbose = verbose, ...) det1<-tmp$det1 lre1<-tmp$lre lreA1<-tmp$lreA det2<-tmp2$det1 lre2<-tmp2$lreA lreA2<-tmp2$lreA } if(same.grid){ l<-list(x1 = x1, x2 = x2, det1 = det1, det2 = det2, lre = lre1, lreA = lreA1) class(l)<-append(class(l),c("cnlt","biv","SG")) return(l) } else{ l<-list(x1 = x1, x2 = x2, det1 = det1, det2 = det2, lre1 = lre1, lre2 = lre2, lreA1 = lreA1, lreA2 = lreA2) class(l)<-append(class(l),c("cnlt","biv","DG")) return(l) } }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/cnlt.biv.R
cnlt.spec.DG <-function(x, M = 50, fact = 1, ...){ cnlt.obj<-x # check if we have the right object: if("DG"%in%class(cnlt.obj)){ x1<-cnlt.obj$x1 x2<-cnlt.obj$x2 } else{ stop("Please supply appropriate cnlt object!") } # compute "pre periodograms" C1 <- pre.per(x1, sapply(cnlt.obj$det1,Re), cnlt.obj$lre1, cnlt.obj$lreA1, ...) C2 <- pre.per(x2, sapply(cnlt.obj$det2,Re), cnlt.obj$lre2, cnlt.obj$lreA2, ...) Q1 <- pre.per(x1, sapply(cnlt.obj$det1,Im), cnlt.obj$lre1, cnlt.obj$lreA1, ...) Q2 <- pre.per(x2, sapply(cnlt.obj$det2,Im), cnlt.obj$lre2, cnlt.obj$lreA2, ...) # sample appropriately to make sure they have the same number of coefficients C12 <- pre.per.sample(C1$spec, C2$spec) Q12 <- pre.per.sample(Q1$spec, Q2$spec) # combine pre periodogram # cross terms CR1 <- pre.per.comb(C12$spec1, C12$spec2) CR2 <- pre.per.comb(Q12$spec1, Q12$spec2) QR1 <- pre.per.comb(Q12$spec1, C12$spec2) QR2 <- pre.per.comb(C12$spec1,Q12$spec2) # individual periodograms R1 <- pre.per.comb(C12$spec1, C12$spec1) I1 <- pre.per.comb(Q12$spec1, Q12$spec1) R2 <- pre.per.comb(C12$spec2, C12$spec2) I2 <- pre.per.comb(Q12$spec2, Q12$spec2) # combine elements PerC <- CR1+CR2 PerQ <- -(QR1-QR2) PerR <- R1+I1 PerI <- R2+I2 # smooth over time PC <- smooth.over.time(C1$mtime, PerC, M = M, fact = fact) PQ <- smooth.over.time(C1$mtime, PerQ, M = M, fact = fact) F1 <- smooth.over.time(C1$mtime, PerR, M = M, fact = fact) F2 <- smooth.over.time(C1$mtime, PerI, M = M, fact = fact) coh <- sqrt(PC^2+PQ^2)/sqrt(F1*F2) phase <- atan(-PQ/PC) l<-list(coh = coh, phase = phase, C = PC, Q = PQ, S1 = F1, S2 = F2, mscale = C1$mscale, mtime = C1$mtime) class(l)<-append(class(l),c(class(cnlt.obj),"spec")) return(l) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/cnlt.spec.DG.R
cnlt.spec <- function(x, ...) UseMethod("cnlt.spec", x)
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/cnlt.spec.R
cnlt.spec.SG <-function(x, M = 50, fact = 1, ...){ cnlt.obj<-x # this functions does scale and time smoothing for cnlt.univ and cnlt.biv (same grid) objects. # output from cnlt.univ has entries: x det lre lreA # output from cnlt.biv has entries: x1 x2 det1 det2 lre lreA (same grid) # check which spectral object we have: if("SG"%in%class(cnlt.obj)){ if("univ"%in%class(cnlt.obj)){ univ<-TRUE # convenience for subclass indicator x1<-cnlt.obj$x } else{ univ<-FALSE x1<-cnlt.obj$x1 # same as cnlt.obj$x2 } } else{ # the object is of the wrong type stop("Please supply a valid cnlt object!") } if(univ){ # smooth individual spectra - these must be positive PerA1 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Re), sapply(cnlt.obj$det1,Re), cnlt.obj$lre, cnlt.obj$lreA, positive = TRUE, ...) PerA11 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Im), sapply(cnlt.obj$det1,Im), cnlt.obj$lre, cnlt.obj$lreA, positive = TRUE, ...) # smooth all spectral quantities over time P1 <- smooth.over.time(x1, spec=PerA1$spec, M = M, fact = fact) P11 <- smooth.over.time(x1, spec=PerA11$spec, M = M, fact = fact) S11 = (P1+P11) l<-list(S1 = S11, mscale = PerA1$mscale, mtime = x1) } else{ # bivariate series # elements of c PerCR1 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Re), sapply(cnlt.obj$det2,Re), cnlt.obj$lre, cnlt.obj$lreA, positive = FALSE, ...) PerCR2 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Im), sapply(cnlt.obj$det2,Im), cnlt.obj$lre, cnlt.obj$lreA, positive = FALSE, ...) #combine PerC <- PerCR1$spec + PerCR2$spec # elements of q (the cross terms!!) PerQR1 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Im), sapply(cnlt.obj$det2,Re), cnlt.obj$lre, cnlt.obj$lreA, positive = FALSE, ...) PerQR2 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Re), sapply(cnlt.obj$det2,Im), cnlt.obj$lre, cnlt.obj$lreA, positive = FALSE, ...) # combine PerQ <- -(PerQR1$spec - PerQR2$spec) # and the individual spectra - these must be positive PerA1 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Re), sapply(cnlt.obj$det1,Re), cnlt.obj$lre, cnlt.obj$lreA, positive = TRUE, ...) PerA2 <- smooth.over.scale(x1, sapply(cnlt.obj$det2,Re), sapply(cnlt.obj$det2,Re), cnlt.obj$lre, cnlt.obj$lreA, positive = TRUE, ...) PerA11 <- smooth.over.scale(x1, sapply(cnlt.obj$det1,Im), sapply(cnlt.obj$det1,Im), cnlt.obj$lre, cnlt.obj$lreA, positive = TRUE, ...) PerA22 <- smooth.over.scale(x1, sapply(cnlt.obj$det2,Im), sapply(cnlt.obj$det2,Im), cnlt.obj$lre, cnlt.obj$lreA, positive = TRUE, ...) # smooth all spectral quantities over time PC <- smooth.over.time(x1, spec=PerC, M = M, fact = fact) PQ <- smooth.over.time(x1, spec=PerQ, M = M, fact = fact) P1 <- smooth.over.time(x1, spec=PerA1$spec, M = M, fact = fact) P2 <- smooth.over.time(x1, spec=PerA2$spec, M = M, fact = fact) P11 <- smooth.over.time(x1, spec=PerA11$spec, M = M, fact = fact) P22 <- smooth.over.time(x1, spec=PerA22$spec, M = M, fact = fact) S11 <- P1 + P11 S22 <- P2 + P22 coh <- sqrt(PC^2 + PQ^2)/sqrt(S11*S22) # coherence phase <- atan(-PQ/PC) # phase l<-list(coh = coh, phase = phase, C = PC, Q = PQ, S1 = S11, S2 = S22, mscale = PerA1$mscale, mtime = x1) } class(l)<-append(class(l),c(class(cnlt.obj),"spec")) return(l) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/cnlt.spec.SG.R
cnlt.univ <-function (x, f, P = 100, nkeep = 2, verbose = TRUE, ...){ dl <- ll <- ll2<- list() if (verbose) { pb <- txtProgressBar(min = 0, max = 100, style = 3) } for (i in 1:P) { if (verbose) { setTxtProgressBar(pb, 100 * i/P) } veci <- sample(1:length(x), length(x) - nkeep, FALSE) ff <- fwtnppermC(x, f, nkeep = nkeep, mod = veci, ...) dl[veci] <- mapply(c, dl[veci], as.list(ff$coeffv[as.vector(veci)])) ll[veci] <- mapply(c, ll[veci], as.list(ff$lengthsremove)) ll2[veci] <- mapply(c, ll2[veci], as.list(ff$Ialpha)) } cat("\n") l<-list(x = x, det1 = dl, lre = ll, lreA = ll2) class(l) <- append(class(l),c("cnlt","univ","SG")) return(l) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/cnlt.univ.R
cnltspec.plot <-function(spec, timevec, scalevec, zrange = NULL, xtitle = "Time", ytitle= "Scale", col.scale = tim.colors(64)[1:45], SFratio = 2, dt = 1, parsw = 3, axis4 = FALSE, frequencies = NULL){ # dt is the sampling interval (e.g dt = 60 is plotting minutes) # other colour options include: # grey col=gray((32:0)/32) # rainbow, e.g. col= rainbow(n=50,start=(0.6)/6, end=2/6) scaleP <- unique(round(scalevec)) #scale range freqP <- (SFratio*2^scaleP)/dt #frequency range ### adding a legend strip "by hand" switch(parsw, { par( mar=c( 3.5,4,2,6.5)) # USED FOR 4 way plot }, { par( mar=c( 3.5,4,2,6.5)) # USED FOR 2 way plot }, { par( mar=c( 5,4,4,7.5)) # USED FOR Single plot }) # plot blank image and fill in required spectral info # remove potential NAs -- this will be zero for coherence and spectral values spec[which(is.na(spec))]<-0 if(is.null(zrange)){ zrange<-range(spec, na.rm = TRUE) } image(sort(timevec),scalevec,t(spec)[order(timevec),], xlab=xtitle,ylab=ytitle, add=FALSE,col=col.scale,zlim=zrange, cex.lab=1, axes=FALSE) axis(1) axis(2) box() if(axis4){ if(is.null(frequencies)){ axis(4, at= scaleP, tick=TRUE, labels= freqP); # automatic method for scale/freq ratio } else{ # JUST PLOT THESE FOURIER FREQUENCIES axis(4, at= logb((frequencies*dt)/2,2), tick=TRUE, labels= frequencies) } } image.plot(sort(timevec),scalevec,t(spec)[order(timevec),],legend.only=TRUE, zlim=zrange, graphics.reset=FALSE,col=col.scale) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/cnltspec.plot.R
pre.per <-function(x, det, lre, lreA, scale.range = NULL, time.range = NULL, Arange = NULL, Jstar = 20, Tstar = 50){ spec2 <- rep(0, Jstar*Tstar) scale.range1 <- range(logb(unlist(lre),2)) min.s <- max(scale.range1[1], scale.range[1]) max.s <- min(scale.range1[2], scale.range[2]) time.range1 <-range(x) min.t <- max(time.range1[1], time.range[1]) max.t <- min(time.range1[2], time.range[2]) # simpler version if nec. #min.s <- scale.range[1] #max.s <- scale.range[2] #min.t <- time.range[1] #max.t <- time.range[2] # discretising the scale scale <- seq(from=min.s, to=(max.s+0.01), length=(Jstar+1)) # add a little on to the max s1 <- scale[1:Jstar] s2 <- scale[2:(Jstar+1)] mscale <- (s1+s2)/2 # discretising the time time <- seq(from=min.t, to=(max.t+0.01), length=(Tstar+1)) # add a little on to the max t1 <- time[1:Tstar] t2 <- time[2:(Tstar+1)] mtime <- (t1+t2)/2 if(is.null(Arange)){ Arange<-c(-Inf,Inf) # set to silly values to include everything } for(k in 1:length(mtime)) { kpoint <- which((x< time[k+1])&(x >= time[k])) mat <- matrix(ncol=3, nrow=length(unlist(lre[kpoint]))) mat[,1] <- logb(unlist(lre[kpoint]),2) mat[,2] <- unlist(det[kpoint]) mat[,3] <- unlist(lreA[kpoint]) #only use the values between a certain alpha range mat <- (mat[(Arange[1]<= mat[,3])&(mat[,3]< Arange[2]),]) #NEEDS TO HAVE MORE THAN ONE VALUE IN MAT! if(length(mat) > 3){ for(i in 1:Jstar){ el <- list(mat[(scale[i]<= mat[,1])&(mat[,1]< scale[i+1]),2]) if(length(el)==0){ el <- NaN } spec2[i+(k-1)*Jstar] <- el } } } spec <- matrix(spec2,nrow=Jstar,ncol=Tstar,byrow=FALSE) list(spec=spec, mscale=mscale,mtime=mtime) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/pre.per.R
pre.per.comb <-function(spec1, spec2){ Nr <- nrow(spec1) Nc <- ncol(spec1) spec <- matrix(nrow=Nr, ncol=Nc) for(i in 1:Nr){ for(k in 1:Nc){ a <- unlist(spec1[i,k]) b <- unlist(spec2[i,k]) MN <- max(length(a),length(b)) # padding for if the lengths are different if(length(a)<MN){ a <- c(a,rep(NaN, (MN-length(a)))) } if(length(b)<MN){ b <- c(b,rep(NaN, (MN-length(a)))) } ab <- a*b spec[i,k] <- mean(ab[is.na(ab)==FALSE]) } } return(spec) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/pre.per.comb.R
pre.per.sample <-function(spec1, spec2){ spec11 <- spec1 spec22 <- spec2 Nr <- nrow(spec1) Nc <- ncol(spec1) #spec <- matrix(nrow=Nr, ncol=Nc) for(i in 1:Nr){ for(k in 1:Nc){ a <- unlist(spec1[i,k]) b <- unlist(spec2[i,k]) MN <- min(length(a),length(b)) #which points to take from each series? s1 <- sample(1:length(a), size=MN, replace = FALSE) s2 <- sample(1:length(b), size=MN, replace = FALSE) aa <- a[sort(s1)] bb <- b[sort(s2)] spec11[i,k] <- list(aa) spec22[i,k] <- list(bb) } } return(list(spec1=spec11, spec2=spec22)) }
/scratch/gouwar.j/cran-all/cranData/CNLTtsa/R/pre.per.sample.R