Skip to content

Version 3 #336

@MassimoCimmino

Description

@MassimoCimmino

Some context

The repository has been idle for a while. I have made some progress towards some of the open issues. However, the current structure of the package and limitations of the finite line source solution make their implementation exponentially more complex as the project grows. In the meantime, we published a journal article (Cimmino, Basquens and Lazzarotto, 2026) introducing a higher order finite line source approach to model borefields. This method is implemented in the package geothermsim. geothermsim is not meant to replace pygfunction. Even though they share similar approaches, geothermsim aims for detailed simulations of borefields while pygfunction aims for rapid evaluation of g-functions.

Development of pygfunction started in 2016 using Python 2.7. Since then, the Python ecosystem progressed massively and, more importantly, our capabilities in the calculation and use of g-functions progressed in ways I could not foresee at the time. The package was simply not structured to accomodate the current and planned features.

To facilitate the development of pygfunction on the long term, I find it valuable to refactor (or rather rewrite) the entire package using the new high order method. A repository for the implementation of the high order method is available here: pygfunction-HigherOrder.

Advantages of the new high order method

The high order method assumes polynomial variations of borehole wall temperatures and heat extraction rates from values at nodes, and therefore relies on the evaluation of finite line sources at these nodes (instead of the average along segments). This makes the extension from vertical to inclined borehole very simple (and is somewhere where the current implementation struggles in pygfunction).

Status of the new repository

Currently implemented features

  • Evaluation of g-functions using the uniform heat transfer rate ('UHTR') and uniform borehole wall temperature ('UBWT') boundary conditions.
  • 'Similarities' method for vertical and inclined boreholes. This already gives some performance upgrades in comparison to pygfunction v2. For example, the g-function of a field of 100 inclined boreholes is evaluated in 5.12 seconds, compared to 482 seconds in v2. This is showcased in the following notebook.
  • A rewrite of the multipole method. It is much faster than the implementation in v2, in parts due to caching of reusable results and also due to a direct solver for the evaluation of multipole strengths (instead of the iterative solver). The plan is to have borefield objects all call the same multipole object to accelerate the (now slow) pre-processing step that precedes the evaluation of g-functions with the 'MIFT' boundary condition. The multipole method is validated in the following notebook.

Features to be implemented to catch up with v2

  • Extension of the borehole and borefield classes to include the evaluation of fluid temperature and heat extraction rate profiles.
  • 'MIFT' boundary condition for the evaluation of g-functions, and variable mass flow rate g-functions.
  • 'Equivalent' solver for the evaluation of g-functions (which relies on the steady-state finite line source solution for the clustering of boreholes).
  • Simulation using load aggregation and other temporal superposition methods.

Other steps before release

  • Docstrings, documentation and examples
  • Tests
  • Formatting (pep8, etc.)

Open issues

Backward-incompatible version

The calculation method is new, which by itself breaks backward compatibility and justifies an increment of the major version up to 3.x. It is then also an opportunity to review the pygfunction workflow (borefield declaration -> g-function evaluation -> simulation). As development progresses, I would appreciate anyone's feedback on the various interfaces and how to simplify the workflow. I will open issues on the new repository on critical aspects but anyone is welcome to comment at any time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions