Showing posts with label water. Show all posts
Showing posts with label water. Show all posts

December 6, 2025

Integrating the rTemp Water Temperature Model into GoldSim Using GSPy

Posted by Jason Lillywhite

This blog post describes a GoldSim model application that integrates the rTemp water temperature model. Originally developed by the Washington State Department of Ecology, the tool calculates the thermal dynamics of water bodies and has been ported to a Python library available for download from the GoldSim Help Center. This example demonstrates how to bridge daily timestep system models with hourly physics calculations, illustrated through a comparison of three distinct method configurations.

What is Response Temperature?

The name rTemp stands for Response Temperature. This is defined as the temperature that a fully mixed column of water would reach if surface heat fluxes were the only heat transfer processes occurring. The model calculates the rate of change in water temperature based on a net heat flux approach, represented by the governing equation:

dT/dt = Jnet / (D × ρw × Cpw)

Where the net heat flux (Jnet) accounts for the gain and loss of heat through:

  • Solar Shortwave Radiation: The largest heat source during the day.
  • Longwave Atmospheric Radiation: Thermal infrared radiation from the atmosphere.
  • Longwave Back Radiation: Heat lost from the water surface.
  • Convection & Evaporation: Driven by wind speed and vapor pressure gradients.
  • Sediment Conduction: Heat exchange with the streambed.

Method Selection

A feature of this Python implementation is the ability to select calculation methods based on available data.

For example, if atmospheric data is limited, the model can use the Bras method for solar radiation and the Brunt method for longwave radiation, which rely primarily on air temperature and turbidity estimates. For applications with detailed data (such as ozone and aerosols), the model can be configured to use the Bird-Hulstrom method. Wind functions can be selected based on the water body type, such as river-specific methods (e.g., Ryan-Harleman) or lake-specific methods (e.g., Marciano-Harbeck).

Screen capture of the GoldSim model with rTemp integration

Integration with GoldSim

This example demonstrates how to use the GSPy Python bridge to incorporate these physics calculations into GoldSim. GoldSim manages the system logic, water balance, and state, while rTemp performs the hourly heat budget calculations.

Because the Python physics engine is stateless, GoldSim acts as the controller, managing the water balance and passing data to Python only when a calculation is required.

Prerequisites

To run this integration, the following tools are required:

  • GoldSim 15 (or later)
  • Python 3.11 or 3.14 (64-bit distribution)
  • GSPy 1.8.8 (The platform-specific C++ bridge DLL)
  • Python Libraries: numpy, pandas, scipy, and the rtemp package.

The rtemp package is installed via pip: pip install git+https://github.com/jlillywh/rTemp.git


The Adapter Script

The integration relies on a Python script (rtemp_goldsim_adapter.py) that interfaces between the two environments. The script performs a temporal reconstruction at each step:

  1. Input & Validation: Accepts current conditions (flow, geometry, meteorology) and validates them. It checks for dry-bed conditions (depth < 0.01m) to prevent numerical instability.
  2. Disaggregation: Converts daily inputs (such as Min/Max Air Temp) into a 24-hour internal profile.
  3. Execution: Runs the rTemp physics engine for 24 hourly iterations.
  4. Return: Calculates final water and sediment temperatures and returns them to GoldSim along with diagnostic data.
Schematic diagram showing how the tools interact
Schematic diagram showing how the tools interact.

Managing State in GoldSim

Since the Python script is stateless, GoldSim must retain the water temperature from the previous timestep. This is achieved using a State Variable Feedback Loop:

  1. An External Element calls the Python script and outputs the New_Water_Temp.
  2. A Previous Value Element captures this result.
  3. In the next timestep, the Previous Value element feeds the temperature back into the External Element as the Initial_Water_Temp.
Screen capture showing how the GoldSim model interfaces with rTemp



Comparing Method Combinations

To demonstrate the application of different physics options, the model was run using three combinations of calculation methods. Each combination was selected to represent specific environmental conditions or data availability:

  • Standard (Bras-Brunt-BGG): The default configuration using Bras solar radiation, Brunt longwave radiation, and Brady-Graves-Geyer wind function. This combination is suitable for general applications.
  • Humid Climate (Ryan-Brutsaert-RH): Uses Ryan-Stolzenbach solar (elevation-aware), Brutsaert longwave, and Ryan-Harleman wind function. This combination is typically applied in humid climates and flowing water.
  • Variable Atmosphere (Iqbal-Brunt-MH): Employs Iqbal solar radiation (visibility-based), Brunt longwave, and Marciano-Harbeck wind function (from Lake Hefner studies). This configuration accounts for variable atmospheric conditions.
Comparison of water temperature predictions using three different method combinations over the simulation period.

While all three scenarios produce similar overall trends, predicted temperatures diverge based on the methodology. The Standard scenario provides a baseline, while the Humid Climate scenario predicts slightly higher temperatures due to reduced evaporative cooling from the Brutsaert longwave method. The Variable Atmosphere scenario demonstrates sensitivity to atmospheric changes via the Iqbal solar radiation method.

These differences indicate the importance of selecting methods appropriate to site conditions. The ability to switch between method combinations within GoldSim facilitates sensitivity analysis and uncertainty quantification. 

Assumptions

The model assumes a well-mixed water column, meaning there is no vertical stratification; the surface temperature is effectively the bulk temperature. This approach is applicable to streams, rivers, and shallow water bodies.

The physics are customizable. The ModelConfiguration can be adjusted within the Python script to toggle between different radiation models or wind functions without changing the GoldSim model structure. Alternatively, the adapter can be configured to control method selection directly from GoldSim using integer codes, enabling dynamic scenario comparison.

Conclusion

The GSPy bridge allows GoldSim to leverage rTemp's physics calculations within a probabilistic framework. This addresses the timescale difference between daily system models and hourly heat budget requirements, providing a solution for water quality modeling.

Download

July 31, 2023

In-Person GoldSim Training - September 13, 2023

Posted by Jason Lillywhite

I will be teaching a 1-day hands-on GoldSim training course at the upcoming Arizona Hydrological Society's Annual Symposium on September 13 in Flagstaff Arizona. Visit their conference website for more information: GoldSim Workshop – 2023 AHS Symposium. We hope to see you there!



September 19, 2016

GoldSim Workshop at AHS Symposium in Tucson

Posted by Jason Lillywhite

GoldSim Technology Group collaborated with the Arizona Hydrological Society last week to provide a 1-day software training workshop as part of their annual conference. The workshop was well attended by folks from various organizations and companies in the area. Following the workshop, I was able to meet new people and learn more about the current water resources issues in the Southwest.
Read about the symposium here.

May 19, 2016

Application of the Markov Process Rainfall Model

Posted by Jason Lillywhite

If you have visited our Model Library lately, you might have noticed that we have a nice little example model that demonstrates the use of a Markov process to simulate daily rainfall. You need to specify some key statistical inputs that have some basis on historic data. How do you develop these inputs? How do you know if the Markov model is realistic? I thought it would be helpful to show how this simple example might be applied in a real-world project and try to answer those questions.

*Note that I made changes to the results on 5/20/2016 after I used GoldSim's optimization function to better calibrate the rate variability.

January 13, 2016

Central Arizona Project - Service Area Model

Posted by Jason Lillywhite

GoldSim is being used by engineers and planners at Central Arizona Project to simulate water management in an area experiencing rapid growth coupled with uncertainties about future water supply, demand and reliability.

The Central Arizona Project Service Area Model (CAP:SAM) was developed by in-house staff using GoldSim software to simulate water demands for all major water using entities in the CAP three county Service Area, and the water supplies they use to meet their demands.  The model can be used to simulate a wide range of future conditions including variable rates and patterns of growth, shortage impacts, effluent reuse, aquifer recharge and recovery, and complex supply portfolio management decisions on an annual time step.

October 20, 2015

Powerful Decision Making for a Phosphate Mine


Posted by Jason Lillywhite

One of the winners of the 2015 User Conference poster session presented on a GoldSim application for a phosphate mine in central Florida. After reading more about this application, I began to better appreciate the great work that Cardno has been involved in. The phosphate mining industry faces very strict effluent limitations while having to manage several hundred gallons of water around the site every day. The model must account for a continuously changing landscape of flow paths and operating schemes under varying hydrologic conditions. Read about how GoldSim is being used to help the mining company make better decisions as they comply with these changing regulations.

July 14, 2015

Modeling Runoff from Multiple Catchments using a Vector Splitter

Posted by Jason Lillywhite

If you have some flow of material or a transaction and need to divide it up or allocate it, likely you will use the Allocator or Splitter element in GoldSim. While these elements are very powerful and make the job a lot easier, there is one condition for which it was not specifically built: handling an array of input amounts. To address this, we have added some nice examples to our library that allow you to simulate allocations and splits on arrays of data. These examples provide an easy way to build powerful models that might have otherwise been quite difficult to build and maintain. I tested the array splitter example model using a real-world example that simulates rainfall runoff in a new stormwater management system, and this is described in this post.

April 16, 2015

GoldSim Applications at the Mine Water Solutions Conference

Posted by Rick Kossik

I've just returned from the Mine Water Solutions in Extreme Environments Conference in Vancouver, BC.  This biennial conference focuses on a wide range of issues associated with mine water management, particularly in extremely wet, dry and cold climates, and with extreme hydrogeological and geochemical issues.  As many of you know, GoldSim is used extensively worldwide for such applications, and as a result, GoldSim was commonly mentioned during the conference.  For example, in one of the keynote sessions, Lisa Wade of GoldCorp (one of the world's largest gold producers), described the company's Water Stewardship Strategy, which it uses to ensure water security and production, reduce costs and impacts, improve operations, and address stakeholder concerns.  During the talk, Lisa mentioned that as part of the Strategy, water management models at the various mine sites are all carried out using GoldSim.  In addition, during the conference a number of technical papers featuring GoldSim were presented. Two such applications are briefly summarized in this post.

April 3, 2015

American Water Resources Association 2015 Conference

Posted by Jason Lillywhite

I recently traveled to sunny Los Angeles, California for the AWRA 2015 Specialty Conference: "Water for Urban Areas: Managing Risks and Building Resiliency." All of the presentations I listened to were very interesting, some of which used GoldSim as the tool to facilitate the studies and results presented. The highlight of the trip, of course, was to visit with some of our customers and make new friends. I also learned more about some of the unique challenges California is facing due to continued population growth, climate change, water quality conditions, and aging infrastructures.