Skip to content

Adding Dynamic Load Aggregation Scheme - #81

Open
mitchute wants to merge 31 commits into
mainfrom
Load_Aggregation
Open

Adding Dynamic Load Aggregation Scheme#81
mitchute wants to merge 31 commits into
mainfrom
Load_Aggregation

Conversation

@mitchute

@mitchute mitchute commented Jul 19, 2023

Copy link
Copy Markdown
Contributor

Pull request overview

  • Summary:
    This pull request introduces a load aggregation scheme to GHEDesigner, enhancing the efficiency of the hourly simulation process while maintaining accuracy. The proposed methodology is based on Claesson and Javed (2012) [1] and Mitchell and Spitler (2019) [2] papers, allowing for faster simulations without compromising reliability.

  • PR resolves (GHEDesginer Limitations number 2)
    "An hourly simulation is available, but it doesn't make use of load aggregation, so is very slow."

  • Key Changes:
    Load Aggregation Method: Implemented load aggregation technique outlined in source papers to streamline simulation by aggregating loads within intervals.
    Faster Hourly Simulation: The new approach significantly reduces computational overhead, enabling faster results while maintaining accuracy.
    Improved Design Workflow: Users can now perform hourly simulations while finding borefield design, eliminating the need for separate simulations, first Hybrid and then Hourly. However, finding design in Hybrid is still the fastest, and gives reliable results in my experience.
    Enhanced Performance: GHEDesigner's overall performance is improved, making it suitable for larger simulations and complex heat exchange systems.

  • Expected Benefits:
    Reduced Computational Time: Load aggregation should significantly decrease the time required for hourly simulations.
    Scalability: GHEDesigner will be able to handle larger and more complex systems with improved performance.
    Consistent Results: Despite speed improvements, the methodology ensures reliable results for design and analysis with minimum absolute error.

  • Comparison between Methods:
    This section presents a comprehensive comparison of simulation methods employed in the study. Specifically, the performance of the Hybrid and Load Aggregated Hourly methods is assessed relative to the Hourly simulation, which serves as the standard reference.

A 30-year simulation on Atlanta Office building with 156 boreholes is conducted to evaluate the efficacy of each method in calculating maximum and minimum Hourly Peak Extraction Fluid Temperatures (HPEFTs), alongside the computational efficiency measured in terms of simulation times.

The error is calculated as the difference between hourly simulation and load aggregated hourly simulation. I can be observed for the 30 years of simulation, that stands to have a maximum absolute value of 0.2 °C.

Error_30_year_Simulation

The error profile is similar as the 1 year simulation getting repeated each year for this load, as shown below:

Error_1_year_Simulation

As the hourly load aggregation depends on expansion rate and number of bins at each level, we followed the suggestions from Mitchell and Spitler paper, where they optimized the ideal expansion rate could be 1.62 or the Golden ratio [2].

For the first 48 hours of the 30 years of simulation, the aggregated simulation and hourly simulation predicts almost the same temperature:

First 48 hours

And for the last 48 hours of the simulation also gives pretty accurate results:

last 48 hours

Upon scrutinizing the maximum and minimum HPEFTs, the Load Aggregation scheme exhibits a maximum absolute error of 0.024°C and 0.004°C, respectively. Notably, these deviations remain within acceptable limits, especially when compared to the Hybrid timestep method. The maximum absolute error for the whole hourly simulation period is 0.2°C.

Simulation_absolute_error

Regarding simulation time, the Load Aggregation method showcases a remarkable improvement, completing the simulation approximately 106 times faster than the conventional Hourly method. However, it is important to note that the Hybrid timestep method outperforms both, achieving a speed enhancement of 15089 times compared to the Hourly method. This efficiency disparity arises from the Hybrid method's monthly simulation frequency as opposed to the hourly frequency of the other methods, resulting in difference in array sizes. The 30-year hourly simulation required approximately 16 minutes to complete, while the Load Aggregation method accomplished the similar task in just 9 seconds.

Simulation_time_fraction

It is worth to note that, the higher is the simulation duration, the load aggregation becomes more time saving. For example, when a 150 hours of Hourly simulation takes about 9 hours and 30 minutes, it takes only 34 seconds with load aggregation scheme, saving 99.9% of computational time. However a 1 year of simulation, takes less than a second for both hourly and load aggregation schemes, where the time saved by aggregation is only 67 %. We have compared the simulation time, and Root Mean Square Error (RMSE) for the whole simulation period for a number of simulation duration, and found the following results:

Time_Saved

Thus the simulation time expands exponentially with higher simulation duration in such calculations. The computational complexity of determining the heat pump entering fluid temperature can be expressed in big O notation as O(n!), where 'n' represents the number of time steps utilized in the simulation.

The following chart is presented for a better visualization:

Simulation_Times

For a more detailed comparison with numerical values, please refer to the following table:

table_comparison

  • Request for Review:
    Feedback, suggestions, and testing are requested from the development team and community members to ensure the stability and effectiveness of the load aggregation feature.

Thank you for your contributions!
Ishraque Zaman Borshon

References:
[1] Claesson, Johan, and Saqib Javed. "A load-aggregation method to calculate extraction temperatures of borehole heat exchangers." Ashrae Transactions 118, no. 1 (2012): 530-540.
[2] Mitchell, Matt S., and Jeffrey D. Spitler. "Characterization, testing, and optimization of load aggregation methods for ground heat exchanger response-factor models." Science and Technology for the Built Environment 25, no. 8 (2019): 1036-1051.

Checklist

  • Documentation added/updated
  • CI status: all green or justified

@mitchute

Copy link
Copy Markdown
Contributor Author

Thanks, @ishraque2008. Please add a basic description of the work to the "Pull request overview" above. We also will need a unit test to exercise the new code. I'll also likely provide some comments related to portions of the code soon.

Comment thread ghedesigner/enums.py Outdated
Comment thread ghedesigner/ground_heat_exchangers.py Outdated
Comment thread ghedesigner/ground_heat_exchangers.py Outdated
Comment thread ghedesigner/ground_heat_exchangers.py Outdated
@mitchute

mitchute commented Aug 1, 2023

Copy link
Copy Markdown
Contributor Author

@ishraque2008 thanks for adding the description in the pull request overview, and for cleaning up some of the code. There are two things I would like to see here before this gets merged.

  • a new unit test added here that exercises the new code from the API side (i.e. code-driven approach).
  • a new input file added here that exercises the new code from the input file side.

As I see it currently, the required timestep input field has not been forwarded on through the code, as is noted in the schema here. This would need to happen before anyone can use this new feature. As it stands now, this code is likely unreachable.

@mitchute

Copy link
Copy Markdown
Contributor Author

@ishraque2008 thanks for picking this back up again!

If you'd rather not wait for GitHub to run the tests, which takes 10+ minutes, you can run them locally. After pip installing the requirements (pip install -r requirements.txt), you can run the following command to run the tests locally.

$ pytest

You can also add the -v flag to display verbose output, and the -x flag to stop after a test has failed.

E.g. $ pytest -v, $ pytest -x and combined $ pytest -vx

Depending on your setup there may be a few other tricks that are needed, so if you run into any issues with that let me know and I can help.

@ishraque2008

Copy link
Copy Markdown
Contributor

@ishraque2008 thanks for picking this back up again!

If you'd rather not wait for GitHub to run the tests, which takes 10+ minutes, you can run them locally. After pip installing the requirements (pip install -r requirements.txt), you can run the following command to run the tests locally.

$ pytest

You can also add the -v flag to display verbose output, and the -x flag to stop after a test has failed.

E.g. $ pytest -v, $ pytest -x and combined $ pytest -vx

Depending on your setup there may be a few other tricks that are needed, so if you run into any issues with that let me know and I can help.

@mitchute Sorry about the long delay to pick up. I'll make sure to be more prompt from now on.
And thanks for the guidance! I've followed your instructions to run the tests. It has been a real-time saver! It would take forever otherwise. Please let me know if there's anything else that needs attention.

@mitchute mitchute left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks really good, but I probably will still do a little more testing.

One thing that needs to be changed is to update the following description in the simulation schema.

"description": "This field is currently unused.\n\nSimulation timestep used in ground heat exchanger sizing.\n\n'HYBRID' is the only option currently available."

from ghedesigner.utilities import eskilson_log_times


class TestLoadAggregation(GHEBaseTest):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much preferred if you could update this test to follow this example.

def test_single_u_tube(self):
ghe = GHEManager()
ghe.set_single_u_tube_pipe(
inner_diameter=0.03404, outer_diameter=0.04216, shank_spacing=0.01856,
roughness=1.0e-6, conductivity=0.4, rho_cp=1542000.0)
ghe.set_soil(conductivity=2.0, rho_cp=2343493.0, undisturbed_temp=18.3)
ghe.set_grout(conductivity=1.0, rho_cp=3901000.0)
ghe.set_fluid()
ghe.set_borehole(height=96.0, buried_depth=2.0, diameter=0.140)
ghe.set_simulation_parameters(num_months=240, max_eft=35, min_eft=5, max_height=135, min_height=60)
ghe.set_ground_loads_from_hourly_list(self.get_atlanta_loads())
ghe.set_geometry_constraints_rectangle(length=85.0, width=36.5, b_min=3.0, b_max=10.0)
ghe.set_design(flow_rate=0.5, flow_type_str="borehole")
ghe.find_design()
output_file_directory = self.test_outputs_directory / "TestFindRectangleDesignSingleUTube"
ghe.prepare_results("Project Name", "Notes", "Author", "Iteration Name")
ghe.write_output_files(output_file_directory, "")
u_tube_height = ghe.results.output_dict['ghe_system']['active_borehole_length']['value']
self.assertAlmostEqual(120.49, u_tube_height, delta=0.1)
nbh = ghe.results.borehole_location_data_rows # includes a header row
self.assertEqual(181, len(nbh))

The previous tests were quite verbose. The new approach is a much more compact way to do the same thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I fused the two concepts and made the test even more concise.

Comment thread ghedesigner/manager.py Outdated
continue_if_design_unmet=continue_if_design_unmet
)

timestep = sim_props.get("timestep", "HYBRID").upper()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch. I was not aware of this dict function.

@mitchute

Copy link
Copy Markdown
Contributor Author

From the PR description, above

Reduced Computational Time: The load aggregation scheme is expected to significantly reduce the computational time required for hourly simulations, making GHEDesigner more efficient for various projects.

Scalability: With the load aggregation method, GHEDesigner should be able to handle larger and more complex heat exchange systems with improved performance.

Consistent Results: Despite the speed improvement, the methodology still maintains a high level of accuracy, ensuring reliable results for design and analysis purposes.

It would be fantastic if you could give a few statistics, plots of differences in simulation times and design outputs, or something else to help see what improvements this may or may not offer.

@ishraque2008

Copy link
Copy Markdown
Contributor

This generally looks really good, but I probably will still do a little more testing.

One thing that needs to be changed is to update the following description in the simulation schema.

"description": "This field is currently unused.\n\nSimulation timestep used in ground heat exchanger sizing.\n\n'HYBRID' is the only option currently available."

@mitchute Thanks for your inputs. Let me address all the suggestions.

@ishraque2008

Copy link
Copy Markdown
Contributor

From the PR description, above

Reduced Computational Time: The load aggregation scheme is expected to significantly reduce the computational time required for hourly simulations, making GHEDesigner more efficient for various projects.

Scalability: With the load aggregation method, GHEDesigner should be able to handle larger and more complex heat exchange systems with improved performance.

Consistent Results: Despite the speed improvement, the methodology still maintains a high level of accuracy, ensuring reliable results for design and analysis purposes.

It would be fantastic if you could give a few statistics, plots of differences in simulation times and design outputs, or something else to help see what improvements this may or may not offer.

From the PR description, above

Reduced Computational Time: The load aggregation scheme is expected to significantly reduce the computational time required for hourly simulations, making GHEDesigner more efficient for various projects.

Scalability: With the load aggregation method, GHEDesigner should be able to handle larger and more complex heat exchange systems with improved performance.

Consistent Results: Despite the speed improvement, the methodology still maintains a high level of accuracy, ensuring reliable results for design and analysis purposes.

It would be fantastic if you could give a few statistics, plots of differences in simulation times and design outputs, or something else to help see what improvements this may or may not offer.

@mitchute Done. Please let me know if more statistics are required.

@ishraque2008 ishraque2008 self-assigned this Apr 17, 2024
@ishraque2008 ishraque2008 added the enhancement New feature or request label Apr 17, 2024
@ishraque2008

Copy link
Copy Markdown
Contributor

From the PR description, above

Reduced Computational Time: The load aggregation scheme is expected to significantly reduce the computational time required for hourly simulations, making GHEDesigner more efficient for various projects.

Scalability: With the load aggregation method, GHEDesigner should be able to handle larger and more complex heat exchange systems with improved performance.

Consistent Results: Despite the speed improvement, the methodology still maintains a high level of accuracy, ensuring reliable results for design and analysis purposes.

It would be fantastic if you could give a few statistics, plots of differences in simulation times and design outputs, or something else to help see what improvements this may or may not offer.

From the PR description, above

Reduced Computational Time: The load aggregation scheme is expected to significantly reduce the computational time required for hourly simulations, making GHEDesigner more efficient for various projects.

Scalability: With the load aggregation method, GHEDesigner should be able to handle larger and more complex heat exchange systems with improved performance.

Consistent Results: Despite the speed improvement, the methodology still maintains a high level of accuracy, ensuring reliable results for design and analysis purposes.

It would be fantastic if you could give a few statistics, plots of differences in simulation times and design outputs, or something else to help see what improvements this may or may not offer.

@mitchute Done. Please let me know if more statistics are required.

Hello @mitchute I just added some more data to the description.

@mitchute

mitchute commented May 1, 2024

Copy link
Copy Markdown
Contributor Author

Alright, I think I have done as much as I can at this point. I'm going to need to kick it back to you (@ishraque2008) for some further investigation.

To get here, I have cleaned up the code so we are not passing in duplicated, unnecessary arguments. I have also added another member to the enum for tracking which timestep method is being used, then updated the logic to switch on those enum values instead of the strings that were being passed around. I'm fairly confident all the right code is being hit now once the proper flag is actuated. To my knowledge, I didn't touch any of the new load aggregation code.

However, I think there are still some issues here that warrant further investigation. I looked at the following schemes and sizing periods: Hybrid (20 yr), Hourly with LA (20 yr), Hourly w/o LA (1-8, 10, and 20 yr). See the plots below. (the cases are labeled by the number of months in the sizing period)

In the first plot, we see the GHE ExFT for the Hybrid, Hourly with and w/o LA for 20 years. Over the sizing period, the hourly with LA consistently underpredicts the fluid temp when compared to the straight hourly simulation. In my opinion, this leads to the results of the second plot.

Screenshot 2024-05-01 at 10 54 06 AM

In this plot, we see the total drilling and simulation runtime for the cases noted above. I was expecting the 20-year cases (Hybrid, Hourly w LA, and Hourly w/o LA) to be consistent. However, the case with load aggregation yields a design that is roughly 11% smaller than the other two cases, which in my opinion warrants further investigation.

Screenshot 2024-05-01 at 9 57 19 AM

I also found it strange that the design jumps by roughly 2X when changing the sizing period from 10-20 years, but perhaps this is expected given the loads we're using. @jeffreyspitler, feel free to comment on that point if you think something looks off.

My notebook is attached, so let me know if I missed something. Otherwise, I think you might double-check that your LA algorithm is working as expected.

Compare Results.ipynb.zip

@ishraque2008 ishraque2008 reopened this May 2, 2024
@ishraque2008

Copy link
Copy Markdown
Contributor

Alright, I think I have done as much as I can at this point. I'm going to need to kick it back to you (@ishraque2008) for some further investigation.
To get here, I have cleaned up the code so we are not passing in duplicated, unnecessary arguments. I have also added another member to the enum for tracking which timestep method is being used, then updated the logic to switch on those enum values instead of the strings that were being passed around. I'm fairly confident all the right code is being hit now once the proper flag is actuated. To my knowledge, I didn't touch any of the new load aggregation code.
However, I think there are still some issues here that warrant further investigation. I looked at the following schemes and sizing periods: Hybrid (20 yr), Hourly with LA (20 yr), Hourly w/o LA (1-8, 10, and 20 yr). See the plots below. (the cases are labeled by the number of months in the sizing period)
In the first plot, we see the GHE ExFT for the Hybrid, Hourly with and w/o LA for 20 years. Over the sizing period, the hourly with LA consistently underpredicts the fluid temp when compared to the straight hourly simulation. In my opinion, this leads to the results of the second plot.
Screenshot 2024-05-01 at 10 54 06 AM
In this plot, we see the total drilling and simulation runtime for the cases noted above. I was expecting the 20-year cases (Hybrid, Hourly w LA, and Hourly w/o LA) to be consistent. However, the case with load aggregation yields a design that is roughly 11% smaller than the other two cases, which in my opinion warrants further investigation.
Screenshot 2024-05-01 at 9 57 19 AM
I also found it strange that the design jumps by roughly 2X when changing the sizing period from 10-20 years, but perhaps this is expected given the loads we're using. @jeffreyspitler, feel free to comment on that point if you think something looks off.
My notebook is attached, so let me know if I missed something. Otherwise, I think you might double-check that your LA algorithm is working as expected.
Compare Results.ipynb.zip

Interesting! I thought everything was working pre

Alright, I think I have done as much as I can at this point. I'm going to need to kick it back to you (@ishraque2008) for some further investigation.
To get here, I have cleaned up the code so we are not passing in duplicated, unnecessary arguments. I have also added another member to the enum for tracking which timestep method is being used, then updated the logic to switch on those enum values instead of the strings that were being passed around. I'm fairly confident all the right code is being hit now once the proper flag is actuated. To my knowledge, I didn't touch any of the new load aggregation code.
However, I think there are still some issues here that warrant further investigation. I looked at the following schemes and sizing periods: Hybrid (20 yr), Hourly with LA (20 yr), Hourly w/o LA (1-8, 10, and 20 yr). See the plots below. (the cases are labeled by the number of months in the sizing period)
In the first plot, we see the GHE ExFT for the Hybrid, Hourly with and w/o LA for 20 years. Over the sizing period, the hourly with LA consistently underpredicts the fluid temp when compared to the straight hourly simulation. In my opinion, this leads to the results of the second plot.
Screenshot 2024-05-01 at 10 54 06 AM
In this plot, we see the total drilling and simulation runtime for the cases noted above. I was expecting the 20-year cases (Hybrid, Hourly w LA, and Hourly w/o LA) to be consistent. However, the case with load aggregation yields a design that is roughly 11% smaller than the other two cases, which in my opinion warrants further investigation.
Screenshot 2024-05-01 at 9 57 19 AM
I also found it strange that the design jumps by roughly 2X when changing the sizing period from 10-20 years, but perhaps this is expected given the loads we're using. @jeffreyspitler, feel free to comment on that point if you think something looks off.
My notebook is attached, so let me know if I missed something. Otherwise, I think you might double-check that your LA algorithm is working as expected.
Compare Results.ipynb.zip

It appears there's an unexpected behavior with the method. Right after finals week, I'll investigate further to understand and fix the issue. Thank you @mitchute for putting hard work into investigation and code clean-ups. Implementing the method in the enum is the best choice in my opinion. I did this on my initial commit, as its use is straightforward. And about the 2X jump, I'm uncertain if similar trends are evident in other highly imbalanced load profiles too. Here for the Atlanta Office building, the annual cooling-to-heating load ratio is around 23.

@mitchute

mitchute commented Apr 2, 2025

Copy link
Copy Markdown
Contributor Author

Closing this for now. Feel free to reopen it if you decide to pick it back up.

@mitchute mitchute closed this Apr 2, 2025
@ishraque2008 ishraque2008 reopened this Mar 30, 2026
@ishraque2008

ishraque2008 commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Hi @mitchute , thanks again for your earlier review and for pointing out the discrepancy in the hourly load aggregation results. I picked this back up and reworked the implementation, updated the tests/demo path, and adding new figures and comparison data.

As it appears, I have reproduced the "Balanced" and "Imbalanced" loads as described by your thesis, and it seems the results are very close with the Non-aggregated method for a 20 years of simulation.

For balanced load the comparison looks like having error below 0.1°C.
image

And for imbalanced load it is also good, less than 0.1° C error.
image

However, whenever we take extremely imbalanced load or the "real" building loads, this is not that perfect. For example, for Atlanta office building load (annual cooling-to-heating load ratio is around 23.), it shows error just below 1°C. However, the real picture comparison can be tested with the hybrid load, that shows error above 3°C (Green lines). So the load aggregation is performing better than it acually was.

image

But this is not true for all "real" loads, for example for Chicago Office building, the results are a little better than the synthetic loads:

image

While looking at the sizing results, there are some interesting observations with Atlanta office building, which was missing during my previous implementation. I will show this after showing some results first.

When sizing for a balanced load, the load aggregation method yields borehole heights more consistent with the no-load aggregation method than the hybrid approach does.

Balanced load:
image

And it is followed by the imbalanced load too:
image

The Chicago office building also shows better alignment than the hybrid load:
image

However, for Atlanta office building load, the load aggregation method will show very confusing result:

image

As you can imagine, this is not because the load aggregation method is not performing as expected, rather because of the other methods that depend on the overall design procedure, including iteration during sizing and also while searching optimized borefield grid. During the field search iterations, both the Hybrid and Hourly without load aggregation methods reached the 18×8 configuration (B = 5.00 m) and, interestingly, both reported an excess temperature of 0.01 °C, making this the apparent near-optimal design point.

However, for the same 18×8_B5.00 configuration, the Hourly Load Aggregation method predicted an excess temperature of −0.31°C instead of 0.01°C. Because the search algorithm uses this excess temperature to guide the next iteration, this small deviation caused the subsequent search path to move in a different direction. As a result, the load aggregation workflow proceeded toward 13×6_B7.08 and 15×7_B6.07, ultimately leading to a less optimal design outcome compared with the Hybrid result.

That said, as shown in the earlier comparison plots, the load aggregation method still tracks the Hourly no-load-aggregation solution much more closely overall than the Hybrid method in terms of transient temperature prediction. Therefore, the discrepancy here appears to be primarily a search-path sensitivity issue near the convergence threshold, rather than a fundamental issue with the load aggregation temperature prediction itself. My working files are messy, thats why I am not sharing them here, but would be happy to share any files you think would help you evaluate better. I tested the method with 7-8 other building loads too (which were used for the validation of GHEDesigner), and found, while simulation shows close alignment, the sizing may not always give the best result with load aggregation method.

Finally, the updated results look much better now: the hourly load aggregation case follows the hourly no-load-aggregation case much more closely, and I am no longer seeing the earlier unexpectedly smaller design result. Sorry again for the long gap on this. I have been in the final stretch of wrapping up my PhD, which pulled me away from revisiting this branch sooner, but I wanted to come back with something substantially improved rather than a partial update. I really appreciate your earlier feedback, and especially your notebook was instrumental in helping me track down where the discrepancy was coming from.

While working through this, I also started exploring a few follow-up directions around even faster simulation and surrogate prediction of thermal response behavior, and the preliminary results are quite encouraging. I did not want to overload this PR thread, but I would be happy to share them at your convenience, if you are interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants