-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement midpoint approximation (#16)
* Implement MidPointApproximation * Update tests for medium * Restructure code for responses * Remove old code * Bump version
- Loading branch information
1 parent
9cb89b8
commit 019abc7
Showing
27 changed files
with
263 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
name = "BoreholeNetworksSimulator" | ||
uuid = "b11dda51-a240-44f0-a43d-fea4e1309b86" | ||
authors = ["Marc Basquens <[email protected]>", "Alberto Lazzarotto <[email protected]>"] | ||
version = "0.1.13" | ||
version = "0.1.14" | ||
|
||
[deps] | ||
Bessels = "0e736298-9ec6-45e8-9647-e4fc86a2fe38" | ||
BoreholeResponseFunctions = "40984d4a-ff4b-5bb1-8527-cee9e1eb1c87" | ||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
CoolProp = "e084ae63-2819-5025-826e-f8e611a84251" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
|
@@ -34,8 +33,8 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | |
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
docs = ["Documenter", "Literate"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,3 +179,7 @@ NoBoundary | |
```@docs | ||
DirichletBoundaryCondition | ||
``` | ||
|
||
```@docs | ||
AdiabaticBoundaryCondition | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/modular/boundary_conditions/AdiabaticBoundaryCondition.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
""" | ||
AdiabaticBoundaryCondition <: BoundaryCondition | ||
Option to enforce zero heat flow at the surface plane `z=0`. | ||
""" | ||
struct AdiabaticBoundaryCondition <: BoundaryCondition end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/modular/responses/convolution/ground_water_response.jl
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
function compute_response!(g, medium::Medium, options) | ||
@unpack λ, α = medium | ||
@unpack borefield, boundary_condition, approximation, atol, rtol, t = options | ||
Nb = n_boreholes(borefield) | ||
|
||
for (k, tt) in enumerate(t) | ||
for j in 1:Nb | ||
for i in 1:Nb | ||
rb = get_rb(borefield, i) | ||
s = setup(approximation, medium, borefield, i, j) | ||
g[i, j, k] = response(boundary_condition, s, Constants(α=α, kg=λ, rb=rb), tt, atol=atol, rtol=rtol) | ||
end | ||
end | ||
end | ||
end | ||
|
||
function response(::NoBoundary, setup, params::Constants, t; atol, rtol) | ||
step_response(setup, params, t, atol=atol, rtol=rtol) | ||
end | ||
|
||
function response(::DirichletBoundaryCondition, setup, params::Constants, t; atol, rtol) | ||
setup_image = image(setup) | ||
Ip = step_response(setup, params, t, atol=atol, rtol=rtol) | ||
In = step_response(setup_image, params, t, atol=atol, rtol=rtol) | ||
Ip - In | ||
end | ||
|
||
function response(::AdiabaticBoundaryCondition, setup, params::Constants, t; atol, rtol) | ||
setup_image = image(setup) | ||
Ip = step_response(setup, params, t, atol=atol, rtol=rtol) | ||
In = step_response(setup_image, params, t, atol=atol, rtol=rtol) | ||
Ip + In | ||
end | ||
|
||
step_response(s::SegmentToPoint, params::Constants, t; atol, rtol) = stp_response(s, params, t, atol=atol, rtol=rtol) | ||
step_response(s::SegmentToSegment, params::Constants, t; atol, rtol) = sts_response(s, params, t, atol=atol, rtol=rtol) | ||
|
||
step_response(s::MovingSegmentToPoint, params::Constants, t; atol, rtol) = mstp_response(s, params, t, atol=atol, rtol=rtol) | ||
step_response(s::MovingSegmentToSegment, params::Constants, t; atol, rtol) = msts_response(s, params, t, atol=atol, rtol=rtol) | ||
|
||
function stp_response(s::SegmentToPoint, params::Constants, t; atol, rtol) | ||
@unpack σ, H, D, z = s | ||
@unpack α, kg = params | ||
return fls_step_response(t, σ, z, D, D+H, α, kg, atol=atol, rtol=rtol) | ||
end | ||
|
||
function sts_response(s::SegmentToSegment, params::Constants, t; atol, rtol) | ||
@unpack α, kg = params | ||
params = FiniteLineSource.MeanSegToSegEvParams(s) | ||
r_min, r_max = FiniteLineSource.h_mean_lims(params) | ||
f(r) = FiniteLineSource.h_mean_sts(r, params) * point_step_response(t, r, α, kg) | ||
x, w = FiniteLineSource.adaptive_nodes_and_weights(f, r_min, r_max, atol=atol, rtol=rtol) | ||
return dot(f.(x), w) | ||
end | ||
|
||
function mstp_response(s::MovingSegmentToPoint, params::Constants, t; atol, rtol) | ||
@unpack x, y, H, D, z, v = s | ||
@unpack α, kg = params | ||
return mfls_step_response(t, x, y, z, v, D, D+H, α, kg, atol=atol, rtol=rtol) | ||
end | ||
|
||
function msts_response(s::MovingSegmentToSegment, params::Constants, t; atol, rtol) | ||
@unpack α, kg = params | ||
@unpack x, v, D1, H1, D2, H2 = s | ||
params = FiniteLineSource.MeanSegToSegEvParams(s) | ||
r_min, r_max = FiniteLineSource.h_mean_lims(params) | ||
f(r) = FiniteLineSource.h_mean_sts(r, params) * moving_point_step_response(t, r, x, v, α, kg) | ||
X, W = FiniteLineSource.adaptive_nodes_and_weights(f, r_min, r_max, atol=atol, rtol=rtol) | ||
return dot(f.(X), W) | ||
end | ||
|
||
point_step_response(t, r, α, kg) = erfc(r/(2*sqrt(t*α))) / (4*π*r*kg) | ||
moving_point_step_response(t, r, x, v, α, kg) = exp(-v * (r-x)/ (2α)) * (erfc( (r-t*v) / sqrt(4t*α)) + erfc((r+t*v) / sqrt(4t*α)) * exp(v*r/α) ) / (8π*r*kg) | ||
|
||
fls_step_response(t, σ, z, a, b, α, kg; atol, rtol) = quadgk(ζ -> point_step_response(t, sqrt(σ^2 + (z-ζ)^2), α, kg), a, b, atol=atol, rtol=rtol)[1] | ||
mfls_step_response(t, x, y, z, v, a, b, α, kg; atol, rtol) = quadgk(ζ -> moving_point_step_response(t, sqrt(x^2 + y^2 + (z-ζ)^2), x, v, α, kg), a, b, atol=atol, rtol=rtol)[1] |
Oops, something went wrong.