diff --git a/.github/workflows/runexamples.yml b/.github/workflows/runexamples.yml new file mode 100644 index 0000000..42209ab --- /dev/null +++ b/.github/workflows/runexamples.yml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 397aa50..3035719 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ **/Manifest.toml .vscode .CondaPkg -.pb.gz +**.pb.gz /docs/build/* __pycache__/ \ No newline at end of file diff --git a/Project.toml b/Project.toml index 449e39a..9acbcb5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BoreholeNetworksSimulator" uuid = "b11dda51-a240-44f0-a43d-fea4e1309b86" authors = ["Marc Basquens ", "Alberto Lazzarotto "] -version = "0.1.12" +version = "0.1.13" [deps] Bessels = "0e736298-9ec6-45e8-9647-e4fc86a2fe38" diff --git a/examples/Braedstrup/main.jl b/examples/Braedstrup/main.jl index 5c9ae1f..c12f047 100644 --- a/examples/Braedstrup/main.jl +++ b/examples/Braedstrup/main.jl @@ -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 @@ -48,7 +48,6 @@ options = SimulationOptions( borefield = borefield, fluid = fluid, medium = medium, - approximation = MidPointApproximation(), Δt = Δt, Nt = Nt, configurations = configurations @@ -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) diff --git a/examples/Braedstrup/plots/Braedstrup_borefield.png b/examples/Braedstrup/plots/Braedstrup_borefield.png new file mode 100644 index 0000000..9c2858e Binary files /dev/null and b/examples/Braedstrup/plots/Braedstrup_borefield.png differ diff --git a/examples/Braedstrup/plots/branch1.png b/examples/Braedstrup/plots/branch1.png new file mode 100644 index 0000000..9028115 Binary files /dev/null and b/examples/Braedstrup/plots/branch1.png differ diff --git a/examples/g-function/main.jl b/examples/g-function/main.jl index 9ba78e7..ba5d0c6 100644 --- a/examples/g-function/main.jl +++ b/examples/g-function/main.jl @@ -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) diff --git a/examples/tekniska/constant_m_week.jl b/examples/tekniska/constant_m.jl similarity index 79% rename from examples/tekniska/constant_m_week.jl rename to examples/tekniska/constant_m.jl index e12f561..e40b241 100644 --- a/examples/tekniska/constant_m_week.jl +++ b/examples/tekniska/constant_m.jl @@ -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) \ No newline at end of file +# save("examples/tekniska/plots/const_m_5_years.png", const_m_plot_5_year) \ No newline at end of file diff --git a/examples/tekniska/defs.jl b/examples/tekniska/defs.jl index d432f7a..ab4c30b 100644 --- a/examples/tekniska/defs.jl +++ b/examples/tekniska/defs.jl @@ -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) \ No newline at end of file +# save("examples/tekniska/plots/Q_week.png", weekly) +# save("examples/tekniska/plots/Q_year.png", yearly) \ No newline at end of file diff --git a/examples/tekniska/prop_m.jl b/examples/tekniska/prop_m.jl index 697218c..96e6da2 100644 --- a/examples/tekniska/prop_m.jl +++ b/examples/tekniska/prop_m.jl @@ -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) diff --git a/examples/tekniska/toggle.jl b/examples/tekniska/toggle.jl index 6573774..c4b9095 100644 --- a/examples/tekniska/toggle.jl +++ b/examples/tekniska/toggle.jl @@ -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) \ No newline at end of file +# save("examples/tekniska/plots/toggle.png", toggle_plot) \ No newline at end of file diff --git a/profile.pb.gz b/profile.pb.gz deleted file mode 100644 index 75056e2..0000000 Binary files a/profile.pb.gz and /dev/null differ diff --git a/src/modular/core/SimpleOperator.jl b/src/modular/operators/SimpleOperator.jl similarity index 100% rename from src/modular/core/SimpleOperator.jl rename to src/modular/operators/SimpleOperator.jl diff --git a/test/api/api.jl b/test/api/api.jl new file mode 100644 index 0000000..48484ce --- /dev/null +++ b/test/api/api.jl @@ -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 \ No newline at end of file diff --git a/test/examples/initialize.jl b/test/examples/initialize.jl new file mode 100644 index 0000000..2c2b544 --- /dev/null +++ b/test/examples/initialize.jl @@ -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"]) \ No newline at end of file diff --git a/test/examples/run.jl b/test/examples/run.jl new file mode 100644 index 0000000..154e908 --- /dev/null +++ b/test/examples/run.jl @@ -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") diff --git a/test/runtests.jl b/test/runtests.jl index d79538d..2c9668d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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") @@ -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")