diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index b99f4c2..26a3318 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-21T14:27:07","documenter_version":"1.6.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-21T14:31:57","documenter_version":"1.6.0"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index d762e85..8a39078 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,5 +1,5 @@ -Public API · BoreholeNetworksSimulator.jl

Public API

General

BoreholeNetworksSimulator.initializeFunction
initialize(options::SimulationOptions)

Precompute the objects of each TimeSuperpositionMethod that can be computed ahead of time and return the SimulationContainers of the required size.

source
BoreholeNetworksSimulator.simulate!Function
simulate!(;options::SimulationOptions, operator, containers::SimulationContainers)

Run the simulation defined by options. At the end of simulation, containers.X will contain the results. containers should be the output of initialize.

operator should be a function that returns a BoreholeOperation and with signature operator(i, Tin, Tout, Tb, q, configurations):

  • i::Int is the time step
  • Tin is a vector containing the inlet temperature of each borehole
  • Tout is a vector containing the outlet temperature of each borehole
  • Tb is a vector containing the borehole wall temperature of each borehole
  • q is a vector containing the heat exchanged by each borehole
  • configurations: is the list of possible hydraulic configurations of the borefield.
source
BoreholeNetworksSimulator.BoreholeNetworkType
BoreholeNetwork(branches::Vector)

Representation of the hydraulic connections of the boreholes in the network. Each element in branches should be a vector representing a branch of boreholes connected in series, specified by their identifiers. The first borehole of each branch is assumed to be connected in parallel.

source
BoreholeNetworksSimulator.BoreholeOperationType
BoreholeOperation{T <: Number}(network::BoreholeNetwork, mass_flows:: Vector{T})

Represents a operation state of the network, with network representing the hydraulic configuration and mass_flows a Vector containing the mass flow rate of each branch.

source

Simulation Options

BoreholeNetworksSimulator.SimulationOptionsType
struct SimulationOptions{
+Public API · BoreholeNetworksSimulator.jl

Public API

General

BoreholeNetworksSimulator.initializeFunction
initialize(options::SimulationOptions)

Precompute the objects of each TimeSuperpositionMethod that can be computed ahead of time and return the SimulationContainers of the required size.

source
BoreholeNetworksSimulator.simulate!Function
simulate!(;options::SimulationOptions, operator, containers::SimulationContainers)

Run the simulation defined by options. At the end of simulation, containers.X will contain the results. containers should be the output of initialize.

operator should be a function that returns a BoreholeOperation and with signature operator(i, Tin, Tout, Tb, q, configurations):

  • i::Int is the time step
  • Tin is a vector containing the inlet temperature of each borehole
  • Tout is a vector containing the outlet temperature of each borehole
  • Tb is a vector containing the borehole wall temperature of each borehole
  • q is a vector containing the heat exchanged by each borehole
  • configurations: is the list of possible hydraulic configurations of the borefield.
source
BoreholeNetworksSimulator.BoreholeNetworkType
BoreholeNetwork(branches::Vector)

Representation of the hydraulic connections of the boreholes in the network. Each element in branches should be a vector representing a branch of boreholes connected in series, specified by their identifiers. The first borehole of each branch is assumed to be connected in parallel.

source
BoreholeNetworksSimulator.BoreholeOperationType
BoreholeOperation{T <: Number}(network::BoreholeNetwork, mass_flows:: Vector{T})

Represents a operation state of the network, with network representing the hydraulic configuration and mass_flows a Vector containing the mass flow rate of each branch.

source

Simulation Options

BoreholeNetworksSimulator.SimulationOptionsType
struct SimulationOptions{
                 TSM <: TimeSuperpositionMethod,
                 C <: Constraint,
                 B <: Borefield, 
@@ -15,8 +15,8 @@
     configurations::Vector{BoreholeNetwork}
     Δt
     Nt::Int
-)

Specifies all the options for the simulation.

  • method: time superposition method used to compute the response. Available options: ConvolutionMethod, NonHistoryMethod.
  • constraint: constraint that the system must satisfy. Can be variable with time. Available options: HeatLoadConstraint, InletTempConstraint.
  • borefield: describes the geometrical properties and the boreholes of the borefield on which the simulation will be performed. Available options: EqualBoreholesBorefield.
  • medium: properties of the ground where the borefield is places. Available options: GroundMedium, FlowInPorousMedium.
  • boundary_condition: boundary condition of the domain where the simulation is performed. Available options: NoBoundary, DirichletBoundaryCondition.
  • fluid: properties of the fluid flowing through the hydraulic system.
  • configurations: possible hydraulic topologies possible in the system, including reverse flow.
  • Δt: time step used in the simulation.
  • Nt: total amount of time steps of the simulation.
source

Medium

BoreholeNetworksSimulator.MediumType
abstract type Medium

Interface for mediums.

Required functions:

  • get_λ(::Medium): Return the thermal conductivity of the medium.
  • get_α(::Medium): Return the thermal diffusivity of the medium.
  • get_T0(::Medium): Return the initial temperature of the medium.
  • compute_response!(g, ::Medium, borefield::Borefield, boundary_condition::BoundaryCondition, t): Compute inplace in g the thermal responses between boreholes in borefield, imposing the boundary condition boundary_condition, for all times in t.
source

Options

BoreholeNetworksSimulator.GroundMediumType
GroundMedium{T <: Real} <: Medium @deftype T

Model pure conduction in the ground.

Arguments

  • λ = 3.: ground conductivity
  • α = 1e-6: ground thermal diffusivity
  • C = λ/α: ground medium capacity
  • T0 = 0.: initial ground temperature
source
BoreholeNetworksSimulator.FlowInPorousMediumType
FlowInPorousMedium{T <: Real} <: Medium @deftype T

Model a porous ground with a water flow.

Arguments

  • λw = 0.6: water thermal conductivity
  • λs = 2.: ground thermal conductivity
  • Cw = 4.18*1e6:water thermal capacity
  • Cs = 1.7*1e6: ground thermal capacity
  • θ = 0.: angle of Darcy velocity
  • Φ = 0.2: porosity
  • λ = λs * (1-Φ) + λw*Φ: porous medium conductivity
  • C = Cs * (1-Φ) + Cw*Φ: porous medium capacity
  • α = λ/C: porous medium thermal diffusivity
  • ux_in_meterperday = 1e-2: groundwater speed along the flow coordinate
  • ux = ux_in_meterperday/(3600*24): groundwater speed in m/s
  • vt = ux * Cw/C: porous medium darcy velocity
  • T0 = 0.: initial ground temperature
source

Borefield

BoreholeNetworksSimulator.BorefieldType
abstract type Borefield

Interface for borefields.

Required functions

  • n_boreholes(::Borefield): Return the amount of boreholes present in the borefield.
  • get_H(::Borefield, i): Return the length of borehole i.
  • get_rb(::Borefield, i): Return the radius of borehole i.
  • segment_coordinates(::Borefield): Return a vector with the coordinates of each segment.
  • internal_model_coeffs!(M, ::Borefield, medium, operation, fluid): Compute inplace in M the coefficients corresponding to the internal model equations, given the medium, fluid and operation in use in the system. Note that M is only a slice of Nb (number of boreholes) rows, provided as a view.
  • internal_model_b!(b, ::Borefield): Compute inplace in b the independent terms corresponding to the internal model equations. Note that b is only a vector of length Nb (number of boreholes) rows, provided as a view.
source

Options

BoreholeNetworksSimulator.EqualBoreholesBorefieldType
EqualBoreholesBorefield{T <: Borehole, R <: Medium, S <: Real} <: Borefield
-EqualBoreholesBorefield(borehole_prototype::T, positions::Vector{Point2{S}}), medium::R)

Model a borefield with boreholes all identical to the prototype borehole_prototype, placed at positions. Note that the length of positions determines the amount of boreholes in the field. medium contains the properties of the ground.

source

Borehole

BoreholeNetworksSimulator.BoreholeType
abstract type Borehole

Interface for boreholes.

Required functions:

  • get_H(::Borehole): Return the length of the borehole.
  • get_D(::Borehole): Return the burial depth of the borehole.
  • get_rb(::Borehole): Return the radius of the borehole.
  • uniform_Tb_coeffs(::Borehole, λ, mass_flow, Tref, fluid): Return the internal model coefficients for the resistance network between the pipes and the wall.
source

Options

BoreholeNetworksSimulator.SingleUPipeBoreholeType
SingleUPipeBorehole{T <: Real} <: Borehole @deftype T
-SingleUPipeBorehole(H, D)

Model a borehole with a single U-pipe with burial depth D and length H.

Arguments

  • λg = 2.5: grout conductivity
  • Cg = 2000. * 1550.: grout capacity
  • αg = λg/Cg: grout thermal diffusivity
  • rp = 0.02: pipe radius
  • λp = 0.42: pipe material conductivity
  • dpw = 0.0023: pipe thickness
  • rpo = rp + dpw: equivalent pipe radius
  • hp = 725.: heat transfer coefficient fluid to pipe
  • pipe_position::NTuple{2, Tuple{T, T}} = [(0.03, 0.0), (-0.03, 0.0)]: positions of the downward and upward branches of the pipe. (0, 0) represents the center of the borehole.
  • rb = 0.115/2: borehole radius
source

Constraint

BoreholeNetworksSimulator.ConstraintType
abstract type Constraint

Interface for constraints.

Required functions:

  • constraints_coeffs!(M, ::Constraint, operation::BoreholeOperation): Compute inplace in M the coefficients corresponding to the constraints equations, given the current operation.network. Note that M is only a slice of Nbr (number of branches) rows, provided as a view.
  • constraints_b!(b, ::Constraint, ::BoreholeOperation, step): Compute inplace in b the independent term corresponding to the constraints equations, given the current operation.network, at the time step step. Note that b is only a vector of length Nbr (number of branches), provided as a view.
source

Options

BoreholeNetworksSimulator.HeatLoadConstraintType
HeatLoadConstraint(Q_tot::Matrix{T}){T <: Number} <: Constraint

Constrain the heat extracted per branch.

The heat constraint Q_tot must be a Matrix, whose column i are the loads per branch at the time step i. The amount of rows of Q_tot must equal to the amount of branches specified in BoreholeNetwork.

source
BoreholeNetworksSimulator.InletTempConstraintType
InletTempConstraint(T_in::Matrix{T}){T <: Number} <: Constraint

Constrain the inlet temperature of the first borehole in each branch.

The inlet temperature T_in must be a Matrix, whose column i are the inlet temperatures per branch at the time step i. The amount of rows of T_in must equal to the amount of branches specified in BoreholeNetwork.

source

Time Superposition Method

BoreholeNetworksSimulator.TimeSuperpositionMethodType
abstract type TimeSuperpositionMethod

Interface for time superposition methods.

Required functions:

  • method_coeffs!(M, ::TimeSuperpositionMethod, borefield, medium, boundary_condition): Compute inplace in M the coefficients corresponding to the heat transfer equations, given the medium, and boundary_condition in use in the system. Note that M is only a slice of Nbr (number of branches) rows, provided as a view.
  • method_b!(b, ::TimeSuperpositionMethod, borefield, medium, step): Compute inplace in b the independent terms corresponding to the heat transfer equations, given the medium, at the given time step step. Note that b is only a vector of length Nbr (number of branches) rows, provided as a view.
  • precompute_auxiliaries!(method::TimeSuperpositionMethod; options): Compute inplace in method the auxiliary quantities used in the simulation that can be performed ahead of time.
  • update_auxiliaries!(::TimeSuperpositionMethod, X, borefield, step): Update inplace in method the auxiliaries after each time step step.
source

Options

BoreholeNetworksSimulator.ConvolutionMethodType
ConvolutionMethod{T} <: TimeSuperpositionMethod 
-ConvolutionMethod()

Use the naïve convolution to compute the thermal response between boreholes. It should be initialized without arguments, but it contains the variables:

  • g stores the unit response between each pair of boreholes evaluated at each time of the simulation.

It should be precomputed with initialize.

  • q stores the heat extraction in each borehole at each time step. It is filled as the simulation runs.
source
BoreholeNetworksSimulator.NonHistoryMethodType
NonHistoryMethod{T} <: TimeSuperpositionMethod 
-NonHistoryMethod()

Use the non-history method to compute the thermal response between boreholes. See A non-history dependent temporal superposition algorithm for the finite line source solution. It should be initialized without arguments, but it contains the variables:

  • F::Matrix{T}: each column contains the F function (encoding the load history) for each borehole. It is initially 0.
  • ζ::Vector{T}: discretization nodes of the integration interval. Shared for all boreholes. Precomputed in initialize.
  • w::Matrix{T}: weights of the ζ integration for each pair of boreholes. Precomputed in initialize.
  • expΔt::Vector{T}: exp(-ζ^2*Δt). Precomputed in initialize.
source

Boundary Condition

Options

+)

Specifies all the options for the simulation.

  • method: time superposition method used to compute the response. Available options: ConvolutionMethod, NonHistoryMethod.
  • constraint: constraint that the system must satisfy. Can be variable with time. Available options: HeatLoadConstraint, InletTempConstraint.
  • borefield: describes the geometrical properties and the boreholes of the borefield on which the simulation will be performed. Available options: EqualBoreholesBorefield.
  • medium: properties of the ground where the borefield is places. Available options: GroundMedium, FlowInPorousMedium.
  • boundary_condition: boundary condition of the domain where the simulation is performed. Available options: NoBoundary, DirichletBoundaryCondition.
  • fluid: properties of the fluid flowing through the hydraulic system.
  • configurations: possible hydraulic topologies possible in the system, including reverse flow.
  • Δt: time step used in the simulation.
  • Nt: total amount of time steps of the simulation.
source

Medium

BoreholeNetworksSimulator.MediumType
abstract type Medium

Interface for mediums.

Required functions:

  • get_λ(::Medium): Return the thermal conductivity of the medium.
  • get_α(::Medium): Return the thermal diffusivity of the medium.
  • get_T0(::Medium): Return the initial temperature of the medium.
  • compute_response!(g, ::Medium, borefield::Borefield, boundary_condition::BoundaryCondition, t): Compute inplace in g the thermal responses between boreholes in borefield, imposing the boundary condition boundary_condition, for all times in t.
source

Options

BoreholeNetworksSimulator.GroundMediumType
GroundMedium{T <: Real} <: Medium @deftype T

Model pure conduction in the ground.

Arguments

  • λ = 3.: ground conductivity
  • α = 1e-6: ground thermal diffusivity
  • C = λ/α: ground medium capacity
  • T0 = 0.: initial ground temperature
source
BoreholeNetworksSimulator.FlowInPorousMediumType
FlowInPorousMedium{T <: Real} <: Medium @deftype T

Model a porous ground with a water flow.

Arguments

  • λw = 0.6: water thermal conductivity
  • λs = 2.: ground thermal conductivity
  • Cw = 4.18*1e6:water thermal capacity
  • Cs = 1.7*1e6: ground thermal capacity
  • θ = 0.: angle of Darcy velocity
  • Φ = 0.2: porosity
  • λ = λs * (1-Φ) + λw*Φ: porous medium conductivity
  • C = Cs * (1-Φ) + Cw*Φ: porous medium capacity
  • α = λ/C: porous medium thermal diffusivity
  • ux_in_meterperday = 1e-2: groundwater speed along the flow coordinate
  • ux = ux_in_meterperday/(3600*24): groundwater speed in m/s
  • vt = ux * Cw/C: porous medium darcy velocity
  • T0 = 0.: initial ground temperature
source

Borefield

BoreholeNetworksSimulator.BorefieldType
abstract type Borefield

Interface for borefields.

Required functions

  • n_boreholes(::Borefield): Return the amount of boreholes present in the borefield.
  • get_H(::Borefield, i): Return the length of borehole i.
  • get_rb(::Borefield, i): Return the radius of borehole i.
  • segment_coordinates(::Borefield): Return a vector with the coordinates of each segment.
  • internal_model_coeffs!(M, ::Borefield, medium, operation, fluid): Compute inplace in M the coefficients corresponding to the internal model equations, given the medium, fluid and operation in use in the system. Note that M is only a slice of Nb (number of boreholes) rows, provided as a view.
  • internal_model_b!(b, ::Borefield): Compute inplace in b the independent terms corresponding to the internal model equations. Note that b is only a vector of length Nb (number of boreholes) rows, provided as a view.
source

Options

BoreholeNetworksSimulator.EqualBoreholesBorefieldType
EqualBoreholesBorefield{T <: Borehole, R <: Medium, S <: Real} <: Borefield
+EqualBoreholesBorefield(borehole_prototype::T, positions::Vector{Point2{S}}), medium::R)

Model a borefield with boreholes all identical to the prototype borehole_prototype, placed at positions. Note that the length of positions determines the amount of boreholes in the field. medium contains the properties of the ground.

source

Borehole

BoreholeNetworksSimulator.BoreholeType
abstract type Borehole

Interface for boreholes.

Required functions:

  • get_H(::Borehole): Return the length of the borehole.
  • get_D(::Borehole): Return the burial depth of the borehole.
  • get_rb(::Borehole): Return the radius of the borehole.
  • uniform_Tb_coeffs(::Borehole, λ, mass_flow, Tref, fluid): Return the internal model coefficients for the resistance network between the pipes and the wall.
source

Options

BoreholeNetworksSimulator.SingleUPipeBoreholeType
SingleUPipeBorehole{T <: Real} <: Borehole @deftype T
+SingleUPipeBorehole(H, D)

Model a borehole with a single U-pipe with burial depth D and length H.

Arguments

  • λg = 2.5: grout conductivity
  • Cg = 2000. * 1550.: grout capacity
  • αg = λg/Cg: grout thermal diffusivity
  • rp = 0.02: pipe radius
  • λp = 0.42: pipe material conductivity
  • dpw = 0.0023: pipe thickness
  • rpo = rp + dpw: equivalent pipe radius
  • hp = 725.: heat transfer coefficient fluid to pipe
  • pipe_position::NTuple{2, Tuple{T, T}} = [(0.03, 0.0), (-0.03, 0.0)]: positions of the downward and upward branches of the pipe. (0, 0) represents the center of the borehole.
  • rb = 0.115/2: borehole radius
source

Constraint

BoreholeNetworksSimulator.ConstraintType
abstract type Constraint

Interface for constraints.

Required functions:

  • constraints_coeffs!(M, ::Constraint, operation::BoreholeOperation): Compute inplace in M the coefficients corresponding to the constraints equations, given the current operation.network. Note that M is only a slice of Nbr (number of branches) rows, provided as a view.
  • constraints_b!(b, ::Constraint, ::BoreholeOperation, step): Compute inplace in b the independent term corresponding to the constraints equations, given the current operation.network, at the time step step. Note that b is only a vector of length Nbr (number of branches), provided as a view.
source

Options

BoreholeNetworksSimulator.HeatLoadConstraintType
HeatLoadConstraint(Q_tot::Matrix{T}){T <: Number} <: Constraint

Constrain the heat extracted per branch.

The heat constraint Q_tot must be a Matrix, whose column i are the loads per branch at the time step i. The amount of rows of Q_tot must equal to the amount of branches specified in BoreholeNetwork.

source
BoreholeNetworksSimulator.InletTempConstraintType
InletTempConstraint(T_in::Matrix{T}){T <: Number} <: Constraint

Constrain the inlet temperature of the first borehole in each branch.

The inlet temperature T_in must be a Matrix, whose column i are the inlet temperatures per branch at the time step i. The amount of rows of T_in must equal to the amount of branches specified in BoreholeNetwork.

source

Time Superposition Method

BoreholeNetworksSimulator.TimeSuperpositionMethodType
abstract type TimeSuperpositionMethod

Interface for time superposition methods.

Required functions:

  • method_coeffs!(M, ::TimeSuperpositionMethod, borefield, medium, boundary_condition): Compute inplace in M the coefficients corresponding to the heat transfer equations, given the medium, and boundary_condition in use in the system. Note that M is only a slice of Nbr (number of branches) rows, provided as a view.
  • method_b!(b, ::TimeSuperpositionMethod, borefield, medium, step): Compute inplace in b the independent terms corresponding to the heat transfer equations, given the medium, at the given time step step. Note that b is only a vector of length Nbr (number of branches) rows, provided as a view.
  • precompute_auxiliaries!(method::TimeSuperpositionMethod; options): Compute inplace in method the auxiliary quantities used in the simulation that can be performed ahead of time.
  • update_auxiliaries!(::TimeSuperpositionMethod, X, borefield, step): Update inplace in method the auxiliaries after each time step step.
source

Options

BoreholeNetworksSimulator.ConvolutionMethodType
ConvolutionMethod{T} <: TimeSuperpositionMethod 
+ConvolutionMethod()

Use the naïve convolution to compute the thermal response between boreholes. It should be initialized without arguments, but it contains the variables:

  • g stores the unit response between each pair of boreholes evaluated at each time of the simulation.

It should be precomputed with initialize.

  • q stores the heat extraction in each borehole at each time step. It is filled as the simulation runs.
source
BoreholeNetworksSimulator.NonHistoryMethodType
NonHistoryMethod{T} <: TimeSuperpositionMethod 
+NonHistoryMethod()

Use the non-history method to compute the thermal response between boreholes. See A non-history dependent temporal superposition algorithm for the finite line source solution. It should be initialized without arguments, but it contains the variables:

  • F::Matrix{T}: each column contains the F function (encoding the load history) for each borehole. It is initially 0.
  • ζ::Vector{T}: discretization nodes of the integration interval. Shared for all boreholes. Precomputed in initialize.
  • w::Matrix{T}: weights of the ζ integration for each pair of boreholes. Precomputed in initialize.
  • expΔt::Vector{T}: exp(-ζ^2*Δt). Precomputed in initialize.
source

Boundary Condition

Options

diff --git a/dev/index.html b/dev/index.html index 44f7cc6..a60fefd 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Introduction · BoreholeNetworksSimulator.jl

BoreholeNetworksSimulator.jl is a pure Julia, performant, and modular framework for simulations of fields of boreholes. Features:

  • Computes fluid temperatures, borehole wall temperatures and heat extracted.
  • Highly modular: different boreholes, hydraulic configurations, ground properties, load demand or temperature constraints, ground boundary conditions can be seamlessly used with minimal effort.
  • Allows for design of operation strategies via an operator callback at each time step.
  • Implements the "non-history" time superposition method, reducing the computational complexity in the number of time steps to linear. This allows for simulations with fine time steps.
+Introduction · BoreholeNetworksSimulator.jl

BoreholeNetworksSimulator.jl is a pure Julia, performant, and modular framework for simulations of fields of boreholes. Features:

  • Computes fluid temperatures, borehole wall temperatures and heat extracted.
  • Highly modular: different boreholes, hydraulic configurations, ground properties, load demand or temperature constraints, ground boundary conditions can be seamlessly used with minimal effort.
  • Allows for design of operation strategies via an operator callback at each time step.
  • Implements the "non-history" time superposition method, reducing the computational complexity in the number of time steps to linear. This allows for simulations with fine time steps.
diff --git a/dev/nonhistory/index.html b/dev/nonhistory/index.html index df229e8..e4ea236 100644 --- a/dev/nonhistory/index.html +++ b/dev/nonhistory/index.html @@ -47,7 +47,7 @@ t: StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64} configurations: Array{BoreholeNetwork}((1,))

Let us run the convolution

containers_convolution = @time initialize(options_convolution)
-@time simulate!(operator=operator, options=options_convolution, containers=containers_convolution)
  0.737110 seconds (1.01 M allocations: 67.795 MiB, 3.71% gc time, 97.60% compilation time)
-  5.785180 seconds (9.10 M allocations: 567.996 MiB, 9.00% gc time, 99.95% compilation time)

And now let us run the non-history

containers_nonhistory = @time initialize(options_nonhistory)
-@time simulate!(operator=operator, options=options_nonhistory, containers=containers_nonhistory)
  6.107392 seconds (10.94 M allocations: 381.049 MiB, 1.24% gc time, 31.82% compilation time)
-  0.553159 seconds (756.30 k allocations: 51.365 MiB, 1.92% gc time, 99.87% compilation time)

There is a massive speed up! We can also check that the two solutions are identical

sum(abs.(containers_convolution.X - containers_nonhistory.X))
3.100037292205972

References

[1] Lazzarotto, Alberto; Basquens, Marc; Cimmino, Massimo; Non-history dependent temporal superposition algorithm for the pint source solution, Research Conference Proceedings of the IGSHPA (2024).


This page was generated using Literate.jl.

+@time simulate!(operator=operator, options=options_convolution, containers=containers_convolution)
  0.715417 seconds (1.01 M allocations: 67.752 MiB, 3.58% gc time, 97.52% compilation time)
+  5.645488 seconds (8.88 M allocations: 549.505 MiB, 9.06% gc time, 99.95% compilation time)

And now let us run the non-history

containers_nonhistory = @time initialize(options_nonhistory)
+@time simulate!(operator=operator, options=options_nonhistory, containers=containers_nonhistory)
  6.018368 seconds (10.94 M allocations: 380.889 MiB, 1.17% gc time, 31.24% compilation time)
+  0.541366 seconds (757.15 k allocations: 51.390 MiB, 1.53% gc time, 99.88% compilation time)

There is a massive speed up! We can also check that the two solutions are identical

sum(abs.(containers_convolution.X - containers_nonhistory.X))
3.100037292205972

References

[1] Lazzarotto, Alberto; Basquens, Marc; Cimmino, Massimo; Non-history dependent temporal superposition algorithm for the pint source solution, Research Conference Proceedings of the IGSHPA (2024).


This page was generated using Literate.jl.

diff --git a/dev/python/index.html b/dev/python/index.html index 03a36c9..b72bbfa 100644 --- a/dev/python/index.html +++ b/dev/python/index.html @@ -33,4 +33,4 @@ configurations = configurations )

The code itself is not very different from its Julia version, but there are two remarks worth making. First, we need to call any object defined in Julia by typing jl. in front. This creates a python object with the same fields that juliacall knows how to convert back into a Julia object. Second, note that we have defined the arrays by explicitly declaring their generic type. If we don't do this, they will be converted into Vector{Any} in the Julia code, which is not desirable.

Another difference is the definition of our operator object. Since we are writing python, it should now be a python function, however, since the Julia code is expecting an object of type BoreholeOperation, its return type must be jl.BoreholeOperation, that PythonCall.jl knows how to convert.

def operator(i, Tin, Tout, Tb, q, configurations):
     jl.BoreholeOperation(configurations[0], jl.Array[jl.Float64]([2., 2.]))

Finally we can run the simulation

containers = jl.initialize(options)
-jl.simulate_b(operator=operator, options=options, containers=containers)

Note that the bang in simulate! is replaced by a _b in the juliacall version of the function.

containers.X

Now, one can compare this result with its Julia version. If everything went right, they should agree!

+jl.simulate_b(operator=operator, options=options, containers=containers)

Note that the bang in simulate! is replaced by a _b in the juliacall version of the function.

containers.X

Now, one can compare this result with its Julia version. If everything went right, they should agree!

diff --git a/dev/tutorial/index.html b/dev/tutorial/index.html index e4ad75f..6139026 100644 --- a/dev/tutorial/index.html +++ b/dev/tutorial/index.html @@ -82,7 +82,7 @@ M: SparseArrays.SparseMatrixCSC{Float64, Int64} X: Array{Float64}((8, 120)) [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0] b: Array{Float64}((8,)) [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] -

And finally, we can start the simulation.

@time simulate!(operator=operator, options=options, containers=containers)
  0.157240 seconds (175.21 k allocations: 14.513 MiB, 95.61% compilation time)

The simulation is over! Note that the bulk of the time is spent in the precoputation, while the simulation itself is quite fast. This is especially good if we want to test different operation strategies.

The result is saved in

containers.X
8×120 Matrix{Float64}:
+

And finally, we can start the simulation.

@time simulate!(operator=operator, options=options, containers=containers)
  0.156172 seconds (175.46 k allocations: 14.524 MiB, 95.68% compilation time)

The simulation is over! Note that the bulk of the time is spent in the precoputation, while the simulation itself is quite fast. This is especially good if we want to test different operation strategies.

The result is saved in

containers.X
8×120 Matrix{Float64}:
  11.2798  11.674   11.746   11.8013  …  12.5494  12.5512  12.553   12.5548
  11.22    11.5545  11.6264  11.6818     12.4299  12.4317  12.4334  12.4352
  11.2798  11.674   11.746   11.8013     12.5494  12.5512  12.553   12.5548
@@ -90,4 +90,4 @@
  10.9922  11.0992  11.1712  11.2266     11.9748  11.9766  11.9784  11.9802
  10.9922  11.0992  11.1712  11.2266  …  11.9748  11.9766  11.9784  11.9802
   5.0      5.0      5.0      5.0         5.0      5.0      5.0      5.0
-  5.0      5.0      5.0      5.0         5.0      5.0      5.0      5.0

This page was generated using Literate.jl.

+ 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0

This page was generated using Literate.jl.