--- title: "From observations to project cost" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{From observations to project cost} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4) oldop <- options(width = 100) ``` BasinmodlR follows a geothermal heat project from what is known about the subsurface to its value for the company that would build it. The chain has six steps, each a function that returns a plain table: 1. `project_reservoir()`: aquifer properties at the site; 2. `project_doublet()`: flow, temperature and power of a doublet in each aquifer; 3. `project_demand()`: the heat users; 4. `project_network()`: the transport pipeline and the heat network; 5. `project_costs()`: heat sold, investment and running costs; 6. `project_value()`: cash flow, net present value, debt cover and break-even heat price. `geothermal_project()` runs all six. What differs between countries and companies is kept apart in one object, `project_setup()`, so the chain itself never changes. ```{r} library(BasinmodlR) ``` ## 1. The subsurface: from what is known ### A basin model A burial and thermal history model gives, for every unit, its present depth and thickness, the porosity it kept from its deepest burial (compaction is irreversible) and its temperature. `project_reservoir()` turns the units into aquifers; permeability follows from porosity with a lithology relation (`lithology_table()`) or a relation fitted on well data (`fit_poroperm()`). ```{r} model <- run_basin_model(brabant) aquifers <- project_reservoir(model, site = c(0, 0), lithology = c("layer 4" = "sandstone", "layer 2" = "sandstone")) aquifers[, c("id", "top_depth", "thickness", "porosity", "permeability_md", "gradient_c_km", "porosity_basis")] ``` The Brabant Massif units are old and deeply buried: porosity and permeability are far too low for a doublet. That is the answer for this basin, and the chain carries it through. For the rest of this vignette we use a layer table, the second common starting point. ### A layer table Only depth and thickness are required; lithology, porosity, permeability, temperature and uplift are used when they are given and estimated when they are not. The column `perm_basis` says where each value came from. ```{r} layers <- data.frame(id = c("upper sand", "lower sand"), top_depth = c(1800, 2400), thickness = c(80, 120), lithology = "sandstone", perm_md = c(250, NA), uplift_m = c(0, 300), temp_c = c(70, 88)) res <- project_reservoir(layers, site = c(0, 0)) res[, c("id", "porosity", "permeability_md", "perm_basis", "porosity_basis")] ``` Other inputs feed the same step: `prospect_site()` for one well-known site, `prospects_from_boreholes()` and `prospects_from_grid()` for borehole data and maps, `read_thermogis_aquifer()` for the Dutch ThermoGIS grids, and `sonic_to_porosity()`, `fit_poroperm()` and `calibrate_prospects()` for well logs. ## 2. The set-up: country and company ```{r} nl <- project_setup("NL") nl ``` The Dutch preset uses the reference installation of PBL's SDE++ 2026 advice, the SDE++ 2026 subsidy and PBL's project-finance terms. A greenhouse grower in the same country has its own financing and tax position: ```{r} grower <- project_setup("NL", investor = "grower", subsidy = NULL) ``` For a country without a preset everything is given. The values below are only an illustration; use local quotes for wells, plant and networks, the national tax rate and the subsidy that applies. ```{r} other <- project_setup("custom", economics = project_economics(well_cost_coef = c(0.25, 800, 3e5), elec_price = 150, fixed_om_per_kw = 90), investor = "utility", investor_args = list(tax_rate = 0.30), subsidy = list(subsidy_investment(0.4, cap = 1e7), subsidy_production(eur_mwh = 15, years = 10)), description = "illustrative utility in a country with an investment grant and a production premium") other ``` A set-up can be registered under a name for the rest of the session (`register_project_setup()`) and saved with `saveRDS()` to share it within a company. ## 3. The doublet ```{r} dbl <- project_doublet(res, nl, t_return = 35) dbl[, c("id", "pump_bar", "production_temp", "q_m3h", "power_mw", "cop", "status")] ``` The pump pressure follows the ThermoGIS rule (30 percent of the hydrostatic pressure at mid-aquifer) unless the set-up says otherwise. `engine = "screen"` gives the closed-form screen, fast enough for national grids. ## 4. Demand and network ```{r} users <- project_demand(data.frame(id = c("greenhouses", "hospital", "district"), x = c(1500, 1800, 2100), y = c(200, -300, 400), annual_MWh = c(40000, 25000, 30000)), hours = 5000, min_temp_c = 60, return_temp_c = 35, price_eur_gj = 14) users net <- project_network(users, site = c(0, 0)) net$pipe_m ``` Without street data the network is estimated from straight distances. With streets (for example from OpenStreetMap, `read_osm_streets()`), the network is routed along them and every pipe is sized: ```{r} streets <- list() for (k in 0:5) { streets[[length(streets) + 1]] <- data.frame(osm_id = k + 1, seq = 1:2, x = c(0, 2400), y = c(-800, -800) + k * 400) streets[[length(streets) + 1]] <- data.frame(osm_id = k + 11, seq = 1:2, x = c(0, 0) + k * 480, y = c(-800, 1200)) } streets <- do.call(rbind, streets) routed <- project_network(users, site = c(0, 0), streets = streets, setup = nl) routed$network ``` ## 5. and 6. Costs and value, or the whole chain at once ```{r} p <- geothermal_project(res, users, nl, site = c(0, 0)) p ``` The same chain for the grower and for the other set-up: ```{r} for (s in list(grower, other)) { b <- geothermal_project(res, users, s, site = c(0, 0))$best cat(sprintf("%-8s best %s: NPV %.1f M, break-even %.1f per GJ, feasible %s\n", s$investor$type, b$id, b$npv / 1e6, b$breakeven_eur_gj, b$feasible)) } ``` Every intermediate number is in the result, for example the cost items and the cash flow of the chosen aquifer: ```{r} p$best[, c("capex_wells", "capex_plant_pump", "capex_pipeline", "capex_distribution", "capex_connections", "opex_fixed", "opex_pumping", "heat_sold_mwh", "coverage")] head(project_cashflow(p)) ``` ## From one project to a whole country For a region or a country the same ingredients are used on a grid: `subsurface_potential()` samples every aquifer of a ThermoGIS download (or your own grids) and `couple_potential()` tries every allowed cell within pipeline reach of every cluster of clients, with the same costs and investor profiles. `model_audit_report()` writes an HTML report with every step behind the result. These need the packages 'sf' and 'terra': ```{r, eval = FALSE} pot <- subsurface_potential("D:/geothermal/thermogis_webmaps_TNO_RD_new", spacing_m = 1000) groups <- list(client_layer("greenhouses.gpkg", 240, "kWh_m2", sector = "greenhouse"), client_layer("industry.gpkg", "GJ", "GJ", group = "industry", hours = 6000, min_temp_c = 90)) zones <- list(constraint_layer("natura2000.shp", "natura2000")) x <- couple_potential(pot, groups, zones, investor = nl$investor, sde = sde_scheme()) model_audit_report(pot, groups, zones, file = "audit.html") ``` The doublet engine on its own (after DoubletCalc) is described in the help of `doublet_spec()`, `doublet_simulate()` and `doublet_monte_carlo()`; worked case studies are in `system.file("scripts", package = "BasinmodlR")`. ```{r, include = FALSE} options(oldop) ```