Skip to content

Commit

Permalink
Merge pull request #39 from j-c-cook/issue16_gFunctionInterface
Browse files Browse the repository at this point in the history
Modify g-Function interface for use in E+
  • Loading branch information
Jack Cook authored May 23, 2021
2 parents a0015f9 + 2bdbd0c commit c300db6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 43 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# History of changes

## Current Version
## Version 2.0.0 (2021-05-23)

## Enhancements
### Enhancements

* [Issue 25](https://github.com/j-c-cook/cpgfunction/issues/25) - Removes all references to the 3D `h_ij`
segment response matrix. See [PR 30](https://github.com/j-c-cook/cpgfunction/pull/30).
Expand All @@ -19,7 +19,7 @@
future unequal segment lengths should be made possible again.
See [PR 30](https://github.com/j-c-cook/cpgfunction/pull/30).

## New features
### New features

* [Issue 28](https://github.com/j-c-cook/cpgfunction/issues/28) -
The third party library LinearAlgebra (`jcc:la`) is included and made use of for `LU`
Expand All @@ -29,6 +29,12 @@
A boolean toggle option is added for multi-threading for computing the
uniform borehole wall temperature (UBHWT) g-function

### API Changes

* [Issue 16](https://github.com/j-c-cook/cpgfunction/issues/16) - The `uniform borehole wall temperature`
g-function definition is defined for planned use in EnergyPlus with all arguments. Not all the arguments
currently have a purpose, the adaptive discretization and number of thread arguments are place holders.

## Version 1.0.0 (2021-05-12)

### New features
Expand Down
65 changes: 34 additions & 31 deletions include/cpgfunction/gfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,39 @@ using namespace std;

/** The functions will be listed here in the order which they appear in the associated cpp file **/

namespace gt { namespace gfunction {
/**
* Uniform borehole wall temperature (UBWHT) g-function calculation method
*
* This function superimposes the finite line source (FLS) solution to estimate the g-function of a
* geothermal bore field. Each borehole is modeled as a series of finite line source segments, as proposed
* in [CITE: CimminoBernier2014].
*
* @param gfunction
* @param boreholes
* @param time
* @param alpha
* @param nSegments
* @param use_similarities
* @param disp
*/
vector<double> uniform_borehole_wall_temperature(vector<gt::boreholes::Borehole> &boreField,
vector<double> &time, double alpha, int nSegments=12,
bool use_similarities=true, bool multithread=true,
bool display=false);

void _borehole_segments(vector<gt::boreholes::Borehole>& boreSegments,
vector<gt::boreholes::Borehole>& boreholes, int nSegments);
void load_history_reconstruction(vector<double>& q_reconstructed, vector<double>& time,
vector<double>& _time, vector<vector<double> >& Q,
vector<double>& dt, const int p);
void _temporal_superposition(vector<double>& Tb_0, gt::heat_transfer::SegmentResponse &SegRes,
vector<double> &h_ij, vector<double> &q_reconstructed, int p, int &nSources);
void _solve_eqn(vector<double>& x, vector<vector<double>>& A, vector<double>& b);

} } // namespace gt::gfunction
namespace gt {
namespace gfunction {
/**
* Uniform borehole wall temperature (UBWHT) g-function calculation method
*
* This function superimposes the finite line source (FLS) solution to estimate the g-function of a
* geothermal bore field. Each borehole is modeled as a series of finite line source segments, as proposed
* in [CITE: CimminoBernier2014].
*
* @param gfunction
* @param boreholes
* @param time
* @param alpha
* @param nSegments
* @param use_similarities
* @param disp
*/
vector<double> uniform_borehole_wall_temperature(
vector<gt::boreholes::Borehole> &boreField,
vector<double> &time, double alpha, int nSegments=12,
bool use_similarities=true, bool adaptive=true, int n_Threads=1,
bool multi_thread=true, bool display=false);

void _borehole_segments(vector<gt::boreholes::Borehole>& boreSegments,
vector<gt::boreholes::Borehole>& boreholes, int nSegments);
void load_history_reconstruction(vector<double>& q_reconstructed, vector<double>& time,
vector<double>& _time, vector<vector<double> >& Q,
vector<double>& dt, const int p);
void _temporal_superposition(vector<double>& Tb_0, gt::heat_transfer::SegmentResponse &SegRes,
vector<double> &h_ij, vector<double> &q_reconstructed, int p, int &nSources);
void _solve_eqn(vector<double>& x, vector<vector<double>>& A, vector<double>& b);

} // namespace gt
} // namespace gfunction

#endif //CPPGFUNCTION_GFUNCTION_H
20 changes: 11 additions & 9 deletions src/gfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ using namespace std; // lots of vectors, only namespace to be used
namespace gt { namespace gfunction {
// The uniform borehole wall temperature (UBWHT) g-function calculation. Originally presented in
// Cimmino and Bernier (2015) and a later paper on speed improvements by Cimmino (2018)
vector<double> uniform_borehole_wall_temperature(vector<gt::boreholes::Borehole> &boreField,
vector<double> &time, double alpha, int nSegments,
bool use_similarities, bool multithread, bool display){
vector<double> uniform_borehole_wall_temperature(
vector<gt::boreholes::Borehole> &boreField,
vector<double> &time, double alpha, int nSegments,
bool use_similarities, bool adaptive, int n_Threads,
bool multi_thread, bool display){
vector<double> gFunction(time.size());

if (display) {
Expand Down Expand Up @@ -112,11 +114,11 @@ namespace gt { namespace gfunction {
Hb[b] = boreSegments[b].H;
} // next b
}; // auto _segmentlengths
if (multithread) {
if (multi_thread) {
boost::asio::post(pool, [nSources, &boreSegments, &Hb, &_segmentlengths]{ _segmentlengths(nSources); });
} else {
_segmentlengths(nSources);
} // if (multithread);
} // if (multi_thread);

end = std::chrono::steady_clock::now();
milli = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
Expand All @@ -142,11 +144,11 @@ namespace gt { namespace gfunction {
} // fi
} // next i
}; // auto _fill_time
if (multithread) {
if (multi_thread) {
boost::asio::post(pool, [&_fill_time, &time, &_time]{ _fill_time() ;});
} else {
_fill_time();
} // if (multithread);
} // if (multi_thread);

end = std::chrono::steady_clock::now();
milli = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
Expand Down Expand Up @@ -295,11 +297,11 @@ namespace gt { namespace gfunction {
boost::asio::thread_pool pool3(processor_count);
// A needs filled each loop because the _gsl partial pivot decomposition modifies the matrix
for (int i=0; i<SIZE; i++) {
if (multithread) {
if (multi_thread) {
boost::asio::post(pool3, [&_fillA, i, p, SIZE]{ _fillA(i, p, SIZE) ;});
} else {
_fillA(i, p, SIZE);
} // if (multithread);
} // if (multi_thread);
} // next i
pool3.join();

Expand Down

0 comments on commit c300db6

Please sign in to comment.