Skip to content

1D high-temperature geothermal benchmark ​

Validation  

This example reproduces the 1D high-temperature geothermal benchmark cases from [] using the pressure-enthalpy formulation in Fimbul, and validates the results against HYDROTHERM [] reference solutions.

julia
using Jutul, JutulDarcy, Fimbul, GLMakie

to_celsius(T) = convert_from_si.(T, :Celsius)
to_megapascal(p) = convert_from_si.(p, "megapascal")
to_kj_per_kg(h) = h ./ 1.0e3

const SINGLE_PHASE_CASES = (:a, :b, :c)
const TWO_PHASE_CASES = (:d, :e)
const CASE_COLORS = Dict(
    :a => :blue,
    :b => :red,
    :c => :lightgreen,
    :d => :cyan,
    :e => :magenta,
)
const PROFILE_SPECS = (
    (
        name = :Pressure, label = "Pressure [MPa]", transform = to_megapascal,
        hydrotherm_column = "pressure_mpa",
    ),
    (
        name = :Temperature, label = "Temperature [°C]", transform = to_celsius,
        hydrotherm_column = "temperature_c",
    ),
    (
        name = :Saturations, label = "Liquid saturation [-]", transform = x -> vec(x[1, :]),
        hydrotherm_column = "liquid_saturation",
    ),
)

nx = 200
cell_size = 10.0;

Utilities ​

julia
function simulate_benchmark_case(case_symbol; vertical = false, nx = 100, cell_size = 10.0)

    case = benchmark_ht_1d(
        benchmark_case = case_symbol,
        nx = nx,
        cell_size = cell_size,
        vertical = vertical,
    )
    case = Fimbul.replace_case_timesteps(
        case,
        Fimbul.load_hydrotherm_1d_timesteps(case_symbol, vertical);
        check_sum = true,
    )
    simulator, config = setup_reservoir_simulator(
        case;
        tol_cnv = 1.0e-3,
        tol_mb = 1.0e-7,
        max_timestep = Inf,
        timesteps = :none,
        relaxation = true,
    )
    results = simulate_reservoir(case; simulator = simulator, config = config)
    return (case = case, results = results)
end

function simulate_case_family(case_symbols; nx = 100, cell_size = 10.0)

    outputs = Dict{Tuple{Symbol, Bool}, Any}()
    for case_symbol in case_symbols
        for vertical in Fimbul.available_vertical_modes_ht_1d(case_symbol)
            @info "Simulating case $(case_symbol) with vertical = $(vertical)"
            outputs[(case_symbol, vertical)] = simulate_benchmark_case(
                case_symbol;
                vertical = vertical,
                nx = nx,
                cell_size = cell_size,
            )
        end
    end
    return outputs
end

function reservoir_coordinate(out)
    domain = out.case.model.models[:Reservoir].data_domain
    centroids = tpfv_geometry(physical_representation(domain)).cell_centroids
    if out.case.input_data[:vertical]
        return vec(centroids[3, :])
    else
        return vec(centroids[1, :])
    end
end

function ordered_values(values, vertical)
    values = vec(values)
    return vertical ? reverse(values) : values
end

function plot_property_maps(tables)
    specs = (
        (
            variable = :temperature,
            label = "Temperature [°C]",
        ),
        (
            variable = :density_mix,
            label = "Density [kg/m³]",
        ),
        (
            variable = :saturation_vapor_ph,
            label = "Vapor saturation [-]",
        ),
    )

    fig = Figure(size = (1200, 500))
    for (i, spec) in enumerate(specs)
        yaxisposition = ifelse(i < length(specs), :left, :right)
        ax = Axis(
            fig[2, i];
            xticksmirrored = true, yticksmirrored = true,
            yaxisposition = yaxisposition, aspect = AxisAspect(1)
        )
        handles = Fimbul.plot_phase_diagram_contours!(
            ax,
            tables;
            variable = spec.variable,
            pressure_limits = (1.0e5, 52.5e6),
            enthalpy_limits = (500.0e3, 3500.0e3),
            n_pressure = 500,
            n_enthalpy = 500,
            levels = 18,
            lines = true,
            contourf_kwargs = (; colormap = :seaborn_icefire_gradient),
        )
        Colorbar(
            fig[1, i], handles.filled, vertical = false, flipaxis = true, width = ax.width,
            label = spec.label, labelsize = 20
        )
        if i > 1
            hideydecorations!(ax, ticks = false)
        end
    end
    is_ax = [f isa Axis for f in fig.content]
    linkaxes!(fig.content[is_ax]...)
    return fig
end

function plot_case_profiles(case_symbol, results)
    vertical_modes = Fimbul.available_vertical_modes_ht_1d(case_symbol)
    fig_height = 400 * length(vertical_modes)
    fig = Figure(size = (800 + 400 * (case_symbol ∈ TWO_PHASE_CASES), fig_height))

    for (k, vertical) in enumerate(vertical_modes)
        out = results[(case_symbol, vertical)]
        x = reservoir_coordinate(out)
        state = out.results.states[end]

        row = 2 * (k - 1)
        vertical_label = vertical ? "vertical" : "horizontal"
        for (col, spec) in enumerate(PROFILE_SPECS)
            if spec.name == :Saturations && case_symbol ∉ TWO_PHASE_CASES
                continue
            end
            values = spec.transform(state[spec.name])
            hydrotherm = Fimbul.load_hydrotherm_1d_property(case_symbol, vertical, spec.hydrotherm_column)
            if vertical
                ax = Axis(
                    fig[row + 1, col];
                    xlabel = spec.label,
                    ylabel = "Depth [m]",
                    yreversed = true,
                )
                if hydrotherm !== nothing
                    lines!(
                        ax, hydrotherm.values, hydrotherm.coordinate_m .- cell_size / 2;
                        linewidth = 8, linestyle = :dash, color = :black, label = "HYDROTHERM"
                    )
                end
                lines!(ax, values, x, color = CASE_COLORS[case_symbol], linewidth = 3, label = "Fimbul")
            else
                ax = Axis(
                    fig[row + 1, col];
                    xlabel = "Distance [m]",
                    ylabel = spec.label,
                )
                y = ordered_values(values, vertical)
                if hydrotherm !== nothing
                    lines!(
                        ax, hydrotherm.coordinate_m .- cell_size / 2, hydrotherm.values;
                        linewidth = 8, linestyle = :dash, color = :black, label = "HYDROTHERM"
                    )
                end
                lines!(ax, x, y, color = CASE_COLORS[case_symbol], linewidth = 3, label = "Fimbul")
                if col == 1
                    axislegend(ax; position = :rt)
                end
            end
        end
        fig[row, :] = Label(fig, "Case $(case_symbol) ($(vertical_label))"; fontsize = 20)
    end
    return fig
end;

Simulate all cases ​

julia
all_results = simulate_case_family(
    (SINGLE_PHASE_CASES..., TWO_PHASE_CASES...);
    nx = nx, cell_size = cell_size
);
[ Info: Simulating case a with vertical = false
Jutul: Simulating 250 years, 3.993 weeks as 109 report steps
╭────────────────┬───────────┬───────────────┬──────────╮
│ Iteration type │  Avg/step │  Avg/ministep │    Total │
│                │ 109 steps │ 111 ministeps │ (wasted) │
├────────────────┼───────────┼───────────────┼──────────┤
│ Newton         │   2.02752 │       1.99099 │  221 (0) │
│ Linearization  │   3.04587 │       2.99099 │  332 (0) │
│ Linear solver  │   2.02752 │       1.99099 │  221 (0) │
│ Precond apply  │   4.05505 │       3.98198 │  442 (0) │
╰────────────────┴───────────┴───────────────┴──────────╯
╭───────────────┬─────────┬────────────┬────────╮
│ Timing type   │    Each │   Relative │  Total │
│               │      ms │ Percentage │      s │
├───────────────┼─────────┼────────────┼────────┤
│ Properties    │  0.1126 │     0.88 % │ 0.0249 │
│ Equations     │  5.5693 │    65.17 % │ 1.8490 │
│ Assembly      │  0.1406 │     1.65 % │ 0.0467 │
│ Linear solve  │  0.0306 │     0.24 % │ 0.0068 │
│ Linear setup  │  0.5190 │     4.04 % │ 0.1147 │
│ Precond apply │  0.0378 │     0.59 % │ 0.0167 │
│ Update        │  0.8598 │     6.70 % │ 0.1900 │
│ Convergence   │  1.2722 │    14.89 % │ 0.4224 │
│ Input/Output  │  0.2525 │     0.99 % │ 0.0280 │
│ Other         │  0.6248 │     4.87 % │ 0.1381 │
├───────────────┼─────────┼────────────┼────────┤
│ Total         │ 12.8381 │   100.00 % │ 2.8372 │
╰───────────────┴─────────┴────────────┴────────╯
[ Info: Simulating case a with vertical = true
Jutul: Simulating 749 years, 35.04 weeks as 85 report steps
╭────────────────┬──────────┬──────────────┬──────────╮
│ Iteration type │ Avg/step │ Avg/ministep │    Total │
│                │ 85 steps │ 87 ministeps │ (wasted) │
├────────────────┼──────────┼──────────────┼──────────┤
│ Newton         │  2.03529 │      1.98851 │  173 (0) │
│ Linearization  │  3.05882 │      2.98851 │  260 (0) │
│ Linear solver  │  2.03529 │      1.98851 │  173 (0) │
│ Precond apply  │  4.07059 │      3.97701 │  346 (0) │
╰────────────────┴──────────┴──────────────┴──────────╯
╭───────────────┬──────────┬────────────┬──────────╮
│ Timing type   │     Each │   Relative │    Total │
│               │       μs │ Percentage │       ms │
├───────────────┼──────────┼────────────┼──────────┤
│ Properties    │  90.1944 │    12.39 % │  15.6036 │
│ Equations     │  57.9632 │    11.97 % │  15.0704 │
│ Assembly      │  15.6167 │     3.23 % │   4.0603 │
│ Linear solve  │  29.2414 │     4.02 % │   5.0588 │
│ Linear setup  │ 210.4637 │    28.92 % │  36.4102 │
│ Precond apply │  36.7077 │    10.09 % │  12.7009 │
│ Update        │  23.3348 │     3.21 % │   4.0369 │
│ Convergence   │  68.4190 │    14.13 % │  17.7889 │
│ Input/Output  │  22.8814 │     1.58 % │   1.9907 │
│ Other         │  76.1561 │    10.47 % │  13.1750 │
├───────────────┼──────────┼────────────┼──────────┤
│ Total         │ 727.7213 │   100.00 % │ 125.8958 │
╰───────────────┴──────────┴────────────┴──────────╯
[ Info: Simulating case b with vertical = false
Jutul: Simulating 120 years, 1.331 week as 218 report steps
╭────────────────┬───────────┬───────────────┬──────────╮
│ Iteration type │  Avg/step │  Avg/ministep │    Total │
│                │ 218 steps │ 220 ministeps │ (wasted) │
├────────────────┼───────────┼───────────────┼──────────┤
│ Newton         │   2.29817 │       2.27727 │  501 (0) │
│ Linearization  │   3.30734 │       3.27727 │  721 (0) │
│ Linear solver  │   2.29817 │       2.27727 │  501 (0) │
│ Precond apply  │   4.59633 │       4.55455 │ 1002 (0) │
╰────────────────┴───────────┴───────────────┴──────────╯
╭───────────────┬──────────┬────────────┬──────────╮
│ Timing type   │     Each │   Relative │    Total │
│               │       μs │ Percentage │       ms │
├───────────────┼──────────┼────────────┼──────────┤
│ Properties    │  91.1080 │    12.70 % │  45.6451 │
│ Equations     │  59.8045 │    11.99 % │  43.1191 │
│ Assembly      │  15.5264 │     3.11 % │  11.1945 │
│ Linear solve  │  29.8970 │     4.17 % │  14.9784 │
│ Linear setup  │ 210.4488 │    29.33 % │ 105.4349 │
│ Precond apply │  37.6354 │    10.49 % │  37.7107 │
│ Update        │  23.6050 │     3.29 % │  11.8261 │
│ Convergence   │  68.6507 │    13.77 % │  49.4972 │
│ Input/Output  │  22.6217 │     1.38 % │   4.9768 │
│ Other         │  70.0903 │     9.77 % │  35.1152 │
├───────────────┼──────────┼────────────┼──────────┤
│ Total         │ 717.5608 │   100.00 % │ 359.4980 │
╰───────────────┴──────────┴────────────┴──────────╯
[ Info: Simulating case b with vertical = true
Jutul: Simulating 349 years, 48.81 weeks as 148 report steps
╭────────────────┬───────────┬───────────────┬──────────╮
│ Iteration type │  Avg/step │  Avg/ministep │    Total │
│                │ 148 steps │ 150 ministeps │ (wasted) │
├────────────────┼───────────┼───────────────┼──────────┤
│ Newton         │      2.75 │       2.71333 │  407 (0) │
│ Linearization  │   3.76351 │       3.71333 │  557 (0) │
│ Linear solver  │      2.75 │       2.71333 │  407 (0) │
│ Precond apply  │       5.5 │       5.42667 │  814 (0) │
╰────────────────┴───────────┴───────────────┴──────────╯
╭───────────────┬──────────┬────────────┬──────────╮
│ Timing type   │     Each │   Relative │    Total │
│               │       μs │ Percentage │       ms │
├───────────────┼──────────┼────────────┼──────────┤
│ Properties    │  93.2550 │    13.14 % │  37.9548 │
│ Equations     │  60.5020 │    11.66 % │  33.6996 │
│ Assembly      │  16.8418 │     3.25 % │   9.3809 │
│ Linear solve  │  30.0628 │     4.24 % │  12.2355 │
│ Linear setup  │ 212.8004 │    29.98 % │  86.6098 │
│ Precond apply │  37.6835 │    10.62 % │  30.6744 │
│ Update        │  24.6207 │     3.47 % │  10.0206 │
│ Convergence   │  68.6894 │    13.24 % │  38.2600 │
│ Input/Output  │  22.5313 │     1.17 % │   3.3797 │
│ Other         │  65.5710 │     9.24 % │  26.6874 │
├───────────────┼──────────┼────────────┼──────────┤
│ Total         │ 709.8346 │   100.00 % │ 288.9027 │
╰───────────────┴──────────┴────────────┴──────────╯
[ Info: Simulating case c with vertical = false
Jutul: Simulating 1499 years, 42.08 weeks as 35 report steps
╭────────────────┬──────────┬──────────────┬──────────╮
│ Iteration type │ Avg/step │ Avg/ministep │    Total │
│                │ 35 steps │ 37 ministeps │ (wasted) │
├────────────────┼──────────┼──────────────┼──────────┤
│ Newton         │  2.74286 │      2.59459 │   96 (0) │
│ Linearization  │      3.8 │      3.59459 │  133 (0) │
│ Linear solver  │  2.74286 │      2.59459 │   96 (0) │
│ Precond apply  │  5.48571 │      5.18919 │  192 (0) │
╰────────────────┴──────────┴──────────────┴──────────╯
╭───────────────┬──────────┬────────────┬─────────╮
│ Timing type   │     Each │   Relative │   Total │
│               │       μs │ Percentage │      ms │
├───────────────┼──────────┼────────────┼─────────┤
│ Properties    │  92.3400 │    12.83 % │  8.8646 │
│ Equations     │  61.0204 │    11.74 % │  8.1157 │
│ Assembly      │  16.6088 │     3.20 % │  2.2090 │
│ Linear solve  │  30.6990 │     4.26 % │  2.9471 │
│ Linear setup  │ 214.6886 │    29.82 % │ 20.6101 │
│ Precond apply │  38.0197 │    10.56 % │  7.2998 │
│ Update        │  25.4577 │     3.54 % │  2.4439 │
│ Convergence   │  68.5522 │    13.19 % │  9.1174 │
│ Input/Output  │  23.5576 │     1.26 % │  0.8716 │
│ Other         │  69.0845 │     9.60 % │  6.6321 │
├───────────────┼──────────┼────────────┼─────────┤
│ Total         │ 719.9110 │   100.00 % │ 69.1115 │
╰───────────────┴──────────┴────────────┴─────────╯
[ Info: Simulating case c with vertical = true
Jutul: Simulating 1499 years, 42.08 weeks as 35 report steps
╭────────────────┬──────────┬──────────────┬──────────╮
│ Iteration type │ Avg/step │ Avg/ministep │    Total │
│                │ 35 steps │ 37 ministeps │ (wasted) │
├────────────────┼──────────┼──────────────┼──────────┤
│ Newton         │  2.68571 │      2.54054 │   94 (0) │
│ Linearization  │  3.74286 │      3.54054 │  131 (0) │
│ Linear solver  │  2.68571 │      2.54054 │   94 (0) │
│ Precond apply  │  5.37143 │      5.08108 │  188 (0) │
╰────────────────┴──────────┴──────────────┴──────────╯
╭───────────────┬──────────┬────────────┬─────────╮
│ Timing type   │     Each │   Relative │   Total │
│               │       μs │ Percentage │      ms │
├───────────────┼──────────┼────────────┼─────────┤
│ Properties    │  90.6962 │    12.84 % │  8.5254 │
│ Equations     │  60.4346 │    11.92 % │  7.9169 │
│ Assembly      │  15.8355 │     3.12 % │  2.0744 │
│ Linear solve  │  30.0420 │     4.25 % │  2.8239 │
│ Linear setup  │ 209.7836 │    29.69 % │ 19.7197 │
│ Precond apply │  36.3696 │    10.29 % │  6.8375 │
│ Update        │  25.4906 │     3.61 % │  2.3961 │
│ Convergence   │  67.9417 │    13.40 % │  8.9004 │
│ Input/Output  │  22.4168 │     1.25 % │  0.8294 │
│ Other         │  68.0622 │     9.63 % │  6.3978 │
├───────────────┼──────────┼────────────┼─────────┤
│ Total         │ 706.6135 │   100.00 % │ 66.4217 │
╰───────────────┴──────────┴────────────┴─────────╯
[ Info: Simulating case d with vertical = false
Jutul: Simulating 200 years, 2.002 days as 3087 report steps
╭────────────────┬────────────┬────────────────┬───────────╮
│ Iteration type │   Avg/step │   Avg/ministep │     Total │
│                │ 3087 steps │ 3089 ministeps │  (wasted) │
├────────────────┼────────────┼────────────────┼───────────┤
│ Newton         │    1.97376 │        1.97248 │  6093 (0) │
│ Linearization  │    2.97441 │        2.97248 │  9182 (0) │
│ Linear solver  │    1.97376 │        1.97248 │  6093 (0) │
│ Precond apply  │    3.94752 │        3.94497 │ 12186 (0) │
╰────────────────┴────────────┴────────────────┴───────────╯
╭───────────────┬──────────┬────────────┬────────╮
│ Timing type   │     Each │   Relative │  Total │
│               │       μs │ Percentage │      s │
├───────────────┼──────────┼────────────┼────────┤
│ Properties    │  92.4686 │    11.63 % │ 0.5634 │
│ Equations     │  57.9425 │    10.98 % │ 0.5320 │
│ Assembly      │  14.9963 │     2.84 % │ 0.1377 │
│ Linear solve  │  29.0021 │     3.65 % │ 0.1767 │
│ Linear setup  │ 211.7752 │    26.64 % │ 1.2903 │
│ Precond apply │  38.1763 │     9.60 % │ 0.4652 │
│ Update        │  21.3687 │     2.69 % │ 0.1302 │
│ Convergence   │  56.9520 │    10.80 % │ 0.5229 │
│ Input/Output  │  19.3581 │     1.23 % │ 0.0598 │
│ Other         │ 158.4291 │    19.93 % │ 0.9653 │
├───────────────┼──────────┼────────────┼────────┤
│ Total         │ 794.9525 │   100.00 % │ 4.8436 │
╰───────────────┴──────────┴────────────┴────────╯
[ Info: Simulating case d with vertical = true
Jutul: Simulating 1000 years, 2.127 weeks as 1623 report steps
╭────────────────┬────────────┬────────────────┬──────────╮
│ Iteration type │   Avg/step │   Avg/ministep │    Total │
│                │ 1623 steps │ 1625 ministeps │ (wasted) │
├────────────────┼────────────┼────────────────┼──────────┤
│ Newton         │    2.07086 │        2.06831 │ 3361 (0) │
│ Linearization  │    3.07209 │        3.06831 │ 4986 (0) │
│ Linear solver  │    2.07086 │        2.06831 │ 3361 (0) │
│ Precond apply  │    4.14171 │        4.13662 │ 6722 (0) │
╰────────────────┴────────────┴────────────────┴──────────╯
╭───────────────┬──────────┬────────────┬────────╮
│ Timing type   │     Each │   Relative │  Total │
│               │       μs │ Percentage │      s │
├───────────────┼──────────┼────────────┼────────┤
│ Properties    │ 123.4932 │    16.39 % │ 0.4151 │
│ Equations     │  56.7098 │    11.16 % │ 0.2828 │
│ Assembly      │  14.8696 │     2.93 % │ 0.0741 │
│ Linear solve  │  28.7609 │     3.82 % │ 0.0967 │
│ Linear setup  │ 211.5720 │    28.08 % │ 0.7111 │
│ Precond apply │  37.5295 │     9.96 % │ 0.2523 │
│ Update        │  20.1692 │     2.68 % │ 0.0678 │
│ Convergence   │  53.1989 │    10.47 % │ 0.2652 │
│ Input/Output  │  17.7253 │     1.14 % │ 0.0288 │
│ Other         │ 100.7926 │    13.38 % │ 0.3388 │
├───────────────┼──────────┼────────────┼────────┤
│ Total         │ 753.5237 │   100.00 % │ 2.5326 │
╰───────────────┴──────────┴────────────┴────────╯
[ Info: Simulating case e with vertical = false
Jutul: Simulating 1999 years, 51.39 weeks as 4495 report steps
╭────────────────┬────────────┬────────────────┬────────────╮
│ Iteration type │   Avg/step │   Avg/ministep │      Total │
│                │ 4495 steps │ 4501 ministeps │   (wasted) │
├────────────────┼────────────┼────────────────┼────────────┤
│ Newton         │    2.25184 │        2.24883 │ 10122 (30) │
│ Linearization  │    3.25317 │        3.24883 │ 14623 (32) │
│ Linear solver  │    2.25184 │        2.24883 │ 10122 (30) │
│ Precond apply  │    4.50367 │        4.49767 │ 20244 (60) │
╰────────────────┴────────────┴────────────────┴────────────╯
╭───────────────┬──────────┬────────────┬────────╮
│ Timing type   │     Each │   Relative │  Total │
│               │       μs │ Percentage │      s │
├───────────────┼──────────┼────────────┼────────┤
│ Properties    │ 105.3479 │    14.54 % │ 1.0663 │
│ Equations     │  57.9880 │    11.56 % │ 0.8480 │
│ Assembly      │  15.0161 │     2.99 % │ 0.2196 │
│ Linear solve  │  38.8933 │     5.37 % │ 0.3937 │
│ Linear setup  │ 206.7310 │    28.53 % │ 2.0925 │
│ Precond apply │  37.6687 │    10.40 % │ 0.7626 │
│ Update        │  31.2852 │     4.32 % │ 0.3167 │
│ Convergence   │  59.3189 │    11.83 % │ 0.8674 │
│ Input/Output  │  18.7368 │     1.15 % │ 0.0843 │
│ Other         │  67.4343 │     9.31 % │ 0.6826 │
├───────────────┼──────────┼────────────┼────────┤
│ Total         │ 724.5246 │   100.00 % │ 7.3336 │
╰───────────────┴──────────┴────────────┴────────╯

H2O properties in pressure-enthalpy space ​

The steam tables have been generated using the CoolProp library []–see also FimbulCoolPropExt``). They are available in the model's fluid system, but can also be loaded directly using Artifacts. To generate your own steam tables, see thebuild_steam_tables_h2ofunction inFimbulCoolPropExt`.

We first inspect the steam tables directly. The figure below shows three key properties in (p,h)-space: temperature, density, and vapor saturation. The two-phase envelope is drawn on each subplot.

julia
tables = Fimbul.steam_tables_h2o()
fig_properties = plot_property_maps(tables)
fig_properties

Single-phase benchmark cases ​

Cases :a to :c remain in the single-phase region for the plotted states. We therefore use them to compare Fimbul and HYDROTHERM pressure and temperature profiles along the 1D column, both with and without gravity.

Case a ​

Case :a spans 50 to 25 MPa and 350 to 150 °C. The pressure stays high enough that the fluid remains in the compressed-liquid region throughout the column, so the solution is single-phase liquid with smooth pressure and temperature variations.

julia
fig_case_a = plot_case_profiles(:a, all_results)
fig_case_a

Case b ​

Case :b spans 40 to 20 MPa and 450 to 300 °C. These conditions are hotter than case :a, but the pressure is still high enough to avoid flashing, so the response remains single-phase while showing stronger thermal contrasts.

julia
fig_case_b = plot_case_profiles(:b, all_results)
fig_case_b

Case c ​

Case :c spans 15 to 1 MPa and 500 to 350 °C. Here the fluid is much hotter and less compressed, placing it in the vapor-dominated single-phase region, so the profiles represent hot steam rather than liquid water.

julia
fig_case_c = plot_case_profiles(:c, all_results)
fig_case_c

Two-phase benchmark cases ​

Cases :d and :e traverse the two-phase region. Here we compare Fimbul and HYDROTHERM pressure, temperature, and liquid-saturation profiles, and then compare the no-gravity paths in pressure-enthalpy space.

Case d ​

Case :d spans 20 to 1 MPa and 400 to 150 °C. The inlet starts as hot, pressurized water, but the strong pressure and temperature drop drives the state path across the saturation envelope, producing a genuine two-phase liquid-vapor transition along the column.

julia
fig_case_d = plot_case_profiles(:d, all_results)
fig_case_d

Case e ​

Case :e spans 4 to 1 MPa and 300 to 150 °C. Because the pressures are low, boiling is easier to trigger than in case :d, so the system develops a broad two-phase region with more pronounced vapor formation.

julia
fig_case_e = plot_case_profiles(:e, all_results)
fig_case_e

Phase diagram comparison ​

We compare the horizontal cases directly in pressure-enthalpy space, overlaying Fimbul state paths and HYDROTHERM reference paths on temperature contours.

julia
fig = Figure(size = (700, 640))
Label(fig[0, 1:2], "Phase diagram comparison"; fontsize = 22)
ax = Axis(fig[1, 1]; xticksmirrored = true, yticksmirrored = true, aspect = AxisAspect(1))
handles = Fimbul.plot_phase_diagram_contours!(
    ax,
    tables;
    variable = :temperature,
    pressure_limits = (1.0e5, 52.5e6),
    enthalpy_limits = (500.0e3, 3500.0e3),
    levels = 20,
    lines = true,
)

for case_symbol in (SINGLE_PHASE_CASES..., TWO_PHASE_CASES...)
    hydrotherm = Fimbul.load_hydrotherm_1d_phase_path(case_symbol)
    lines!(ax, hydrotherm.enthalpy_kj_per_kg, hydrotherm.pressure_mpa; linewidth = 6, linestyle = :dash, color = CASE_COLORS[case_symbol])
    out = all_results[(case_symbol, false)]
    state = out.results.states[end]
    Fimbul.plot_reservoir_state_ph!(
        ax,
        state;
        color = CASE_COLORS[case_symbol],
        linewidth = 3,
        label = "Case $(case_symbol)",
    )
end

axislegend(ax; position = :rt)
Colorbar(fig[1, 2], handles.filled, label = "Temperature [°C]")
fig

Download this example ​

Download the Julia script or the Jupyter notebook.

This example took 35.418943954 seconds to complete.

This page was generated using Literate.jl.