Skip to content

Commit

Permalink
Fix (#15)
Browse files Browse the repository at this point in the history
* Fix

* Fix

* Test

* test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Test

* Bump version
  • Loading branch information
marcbasquensmunoz authored Oct 4, 2024
1 parent b761121 commit 9cb89b8
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 19 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/runexamples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run examples

on:
push:
branches:
- main
tags: '*'
pull_request:

jobs:
build:
permissions:
actions: write
contents: write
pull-requests: read
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1.10'
- uses: julia-actions/cache@v2
- name: Install dependencies
run: julia --color=yes test/examples/initialize.jl
- name: Run examples
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia --color=yes test/examples/run.jl
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/Manifest.toml
.vscode
.CondaPkg
.pb.gz
**.pb.gz
/docs/build/*
__pycache__/
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BoreholeNetworksSimulator"
uuid = "b11dda51-a240-44f0-a43d-fea4e1309b86"
authors = ["Marc Basquens <[email protected]>", "Alberto Lazzarotto <[email protected]>"]
version = "0.1.12"
version = "0.1.13"

[deps]
Bessels = "0e736298-9ec6-45e8-9647-e4fc86a2fe38"
Expand Down
9 changes: 4 additions & 5 deletions examples/Braedstrup/main.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using BoreholeNetworksSimulator
using BNSPlots
using CSV
using Statistics
using Colors
using Parameters
using WGLMakie

function load_positions_from_file(file)
data = CSV.read(file, values, header=true, decimal=',')
data = CSV.read(file, values, header=true, decimal=',', delim=';')
data = reduce(hcat, data)
[(data[i, 2], data[i, 3]) for i in 1:size(data)[1]]
end
Expand Down Expand Up @@ -48,7 +48,6 @@ options = SimulationOptions(
borefield = borefield,
fluid = fluid,
medium = medium,
approximation = MidPointApproximation(),
Δt = Δt,
Nt = Nt,
configurations = configurations
Expand Down Expand Up @@ -81,6 +80,6 @@ color_ranges = [(colorant"darkorange", colorant"blue"), (colorant"red", colorant
borefiled_plot = plot_borefield(network, borehole_positions, distinguished_branches = monitored_branches, colors = color_ranges)
branch1 = monitor(containers, network.branches[monitored_branches[1]], options.t, display = [:Tfin], color_pair=color_ranges[1])

save("examples/Braedstrup/plots/Braedstrup_borefield.png", borefiled_plot)
save("examples/Braedstrup/plots/branch1.png", branch1)
# save("examples/Braedstrup/plots/Braedstrup_borefield.png", borefiled_plot)
# save("examples/Braedstrup/plots/branch1.png", branch1)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/Braedstrup/plots/branch1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/g-function/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ make_plot(axis, 0.5*10)
fig[1, 2] = Legend(fig, axis, "", framevisible = false)

fig
save("examples/g-function/gfunction.png", fig)
# save("examples/g-function/gfunction.png", fig)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ containers = @time initialize(options)

t_range = (5*8760-24*7):5*8760
const_m_plot = monitor(containers, [4, 7], options.t, steps = t_range, color_pair = (colorant"darkgreen", colorant"red"))
save("examples/tekniska/plots/const_m.png", const_m_plot)
# save("examples/tekniska/plots/const_m.png", const_m_plot)

const_m_plot_5_year = monitor(containers, [4, 7], options.t, color_pair = (colorant"darkgreen", colorant"red"))
save("examples/tekniska/plots/const_m_5_years.png", const_m_plot_5_year)
# save("examples/tekniska/plots/const_m_5_years.png", const_m_plot_5_year)
4 changes: 2 additions & 2 deletions examples/tekniska/defs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ end
weekly = plot_weekly_Q()
yearly = plot_Q()

#save("examples/tekniska/plots/Q_week.png", weekly)
#save("examples/tekniska/plots/Q_year.png", yearly)
# save("examples/tekniska/plots/Q_week.png", weekly)
# save("examples/tekniska/plots/Q_year.png", yearly)
2 changes: 1 addition & 1 deletion examples/tekniska/prop_m.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ containers = @time initialize(options)
t_range = (5*8760-24*7):5*8760
prop_m_plot = monitor(containers, [4, 7], options.t, steps = t_range, color_pair = (colorant"darkgreen", colorant"red"))

save("examples/tekniska/plots/prop_m.png", prop_m_plot)
# save("examples/tekniska/plots/prop_m.png", prop_m_plot)
2 changes: 1 addition & 1 deletion examples/tekniska/toggle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ containers = @time initialize(options)
t_range = (5*8760-24*7):5*8760
toggle_plot = monitor(containers, [4, 7], options.t, steps = t_range, color_pair = (colorant"darkgreen", colorant"red"))

save("examples/tekniska/plots/toggle.png", toggle_plot)
# save("examples/tekniska/plots/toggle.png", toggle_plot)
Binary file removed profile.pb.gz
Binary file not shown.
File renamed without changes.
49 changes: 49 additions & 0 deletions test/api/api.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

@testset "test_Approximations" begin
@test MeanApproximation() isa Any
#@test MidPointApproximation() isa Any
end

@testset "test_Boreholes" begin
@test SingleUPipeBorehole(H = 100., D = 0.) isa Any
end

@testset "test_Borefields" begin
borehole = SingleUPipeBorehole(H = 100., D = 0.)
@test EqualBoreholesBorefield(borehole_prototype=borehole, positions=[(0., 0.)]) isa Any
end

@testset "test_Boundary_Conditions" begin
@test DirichletBoundaryCondition() isa Any
@test NoBoundary() isa Any
end

@testset "test_Constraints" begin
Nt = 10
Nbr = 10

@test HeatLoadConstraint(rand(Nbr, Nt)) isa Any
@test constant_HeatLoadConstraint(rand(Nbr), Nt) isa Any
@test uniform_HeatLoadConstraint(rand(Nt), Nbr) isa Any

@test InletTempConstraint(rand(Nbr, Nt)) isa Any
@test constant_InletTempConstraint(rand(Nbr), Nt) isa Any
@test uniform_InletTempConstraint(rand(Nt), Nbr) isa Any

@test TotalHeatLoadConstraint(rand(Nt)) isa Any
end

@testset "test_Fluids" begin
@test Water() isa Any
@test EthanolMix() isa Any
end

@testset "test_Mediums" begin
@test FlowInPorousMedium() isa Any
@test GroundMedium() isa Any
end

@testset "test_Methods" begin
@test ConvolutionMethod() isa Any
@test NonHistoryMethod() isa Any
end
17 changes: 17 additions & 0 deletions test/examples/initialize.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Pkg

geothermal_registry = "https://github.com/marcbasquensmunoz/geothermal_registry"

project_directory = joinpath(@__DIR__, "..", "..")
plots_directory = joinpath(project_directory, "BNSPlots")

cd(project_directory) do
Pkg.Registry.add(RegistrySpec(url = geothermal_registry))
Pkg.Registry.add("General")
Pkg.develop(PackageSpec(path = plots_directory))
Pkg.develop(PackageSpec(path = project_directory))
Pkg.activate()
Pkg.instantiate()
end

Pkg.add(["CSV", "Colors", "Parameters", "WGLMakie"])
11 changes: 11 additions & 0 deletions test/examples/run.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

@info "Running Braedstrup"
include("../../examples/Braedstrup/main.jl")
@info "Running g-function"
include("../../examples/g-function/main.jl")
@info "Running Tekniska: constant m"
include("../../examples/tekniska/constant_m.jl")
@info "Running Tekniska: proportional m"
include("../../examples/tekniska/prop_m.jl")
@info "Running Tekniska: toggle"
include("../../examples/tekniska/toggle.jl")
11 changes: 6 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ include("mocks/buffer.jl")
# Check interface implementations
include("test_interfaces.jl")

# Run smoke tests
include("api/api.jl")

# Run unit tests
include("mediums/test_GroundMedium.jl")
include("mediums/test_FlowInPorousMedium.jl")
Expand All @@ -25,9 +28,7 @@ include("boreholes/test_SingleUPipeBorehole.jl")
include("methods/test_ConvolutionMethod.jl")
include("methods/test_NonHistoryMethod.jl")

# Run examples
#include("$(dirname(pwd()))/examples/Braedstrup/main.jl")

# Run tutorials
include("$(dirname(pwd()))/docs/src/tutorial.jl")
include("$(dirname(pwd()))/docs/src/nonhistory.jl")
project_dir = dirname(pwd())
include("$project_dir/docs/src/tutorial.jl")
include("$project_dir/docs/src/nonhistory.jl")

0 comments on commit 9cb89b8

Please sign in to comment.