Skip to main content

"A lightweight open-source Python library for exact view-factor computations on polygonal meshes"

Project description

PyViewFactor

pvf_logo

pyViewFactor is a lightweight open-source Python library for exact view-factor computations on polygonal meshes. It provides robust tools for:

  • geometric visibility analysis,
  • obstruction detection,
  • accurate view factor computation.

Full documentation available here.

Urban View Factor

Latest Release pipeline status codecov License: MIT Pypi Version Pypi Downloads

Features

  • This library enables the computation of radiation view factors between planar polygons using an accurate double‐contour integration method described in (Mazumder and Ravishankar 2012) with insights from (Schmid 2016).
  • It uses the handy Pyvista package to deal with geometry imports (*.stl, *.vtk, *.obj, ...), geometry creations, and some other mesh functionalities under the hood.
  • It enables:
    • 🔺 View factor computation between planar polygons
    • 👁️ Visibility checks based on face orientation
    • 🚧 Obstruction detection using ray-triangle intersection
    • ⚙️ Strict / non-strict modes for robustness control
    • ⚡ Optimized full matrix computation with caching
    • 📦 Built on numpy, scipy, pyvista, numba

Installation

pyViewFactor can be installed from PyPi using pip on Python >= 3.10:

pip install pyviewfactor

You can also visit PyPi or Gitlab to download the sources.

Requirements:

numpy==1.26.4
pyvista==0.45
scipy==1.11.4
numba==0.61.2
tqdm==4.65.0

The code will probably work with lower versions of the required packages, however this has not been tested.

[!NOTE] If you are alergic to numba, you may pip install pyviewfactor==0.0.10 that works (and give up the times 3+ speed-up in view factor computation).

Quick Start

Suppose we want to compute the radiation view factor between a triangle and a rectangle facing each other:

Triangle and rectangle configuration

You are few lines of code away from your first view factor computation:

import pyvista as pv
import pyviewfactor as pvf

# Create a rectangle and a triangle facing each other
pointa1 = [0.0, 0.0, 0.0]
pointb1 = [1.0, 0.0, 0.0]
pointc1 = [0.0, 1.0, 0.0]
rectangle = pv.Rectangle([pointa1, pointb1, pointc1])

pointa2 = [0.0, 0.0, 1.0]
pointb2 = [0.0, 1.0, 1.0]
pointc2 = [1.0, 1.0, 1.0]
triangle = pv.Triangle([pointa2, pointb2, pointc2])

if pvf.get_visibility(rectangle, triangle)[0]:
    F = pvf.compute_viewfactor(triangle, rectangle)
    print("VF from rectangle to triangle :", F)
else:
    print("Not facing each other")

pl = pv.Plotter()
pl.add_mesh(rectangle, color="lightblue", opacity=0.7)
pl.add_mesh(triangle, color="salmon", opacity=0.7)

# compute and glyph normals for mesh1
n1 = rectangle.compute_normals(cell_normals=True, point_normals=False)
arrows1 = n1.glyph(orient="Normals", factor=0.1)
pl.add_mesh(arrows1, color="blue")
# similarly for mesh2
n2 = triangle.compute_normals(cell_normals=True, point_normals=False)
arrows2 = n2.glyph(orient="Normals", factor=0.1)
pl.add_mesh(arrows2, color="darkred")

pl.show()

You usually get your geometry from a different format? (*.dat, *.idf, ...)

Check pyvista's documentation on how to generate a PolyData facet from points.

Documentation

For detailed explanations and advanced usage, see:

https://arep-dev.gitlab.io/pyViewFactor/pyviewfactor.html

The documentation includes:

  • Visibility and obstruction semantics,
  • Strict vs non-strict modes,
  • Geometry preprocessing utilities,
  • Numerical robustness guidelines,
  • Extended examples (that can also be found in the examples/ folder of the repository).

Citation & Acknowledgments

  • Main contributors:
    • Mateusz BOGDAN,
    • Edouard WALTHER.
  • Acknowledgment: The authors would like to acknowledge M. Alecian for his initial work on the quadrature code and M. Chapon for her contribution to the code validation.

There is even a conference paper, showing analytical validations.

So if you use pyViewFactor in your work, please cite:

[!IMPORTANT] Citation: Mateusz BOGDAN, Edouard WALTHER, Marc ALECIAN and Mina CHAPON. Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort. IBPSA France 2022, Châlons-en-Champagne.

Bibtex entry:

@inproceedings{pyViewFactor22bogdan,
  authors      = "Mateusz BOGDAN and Edouard WALTHER and Marc ALECIAN and Mina CHAPON",
  title        = "Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort",
  year         = "2022",
  organization = "IBPSA France",
  venue        = "Châlons-en-Champagne, France"
  note         = "IBPSA France 2022",
}

License

MIT License - Copyright (c) AREP 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyviewfactor-1.0.3.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyviewfactor-1.0.3-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

Details for the file pyviewfactor-1.0.3.tar.gz.

File metadata

  • Download URL: pyviewfactor-1.0.3.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pyviewfactor-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d06e7e7fd1ebb4e762c33fae9016c7a065c8beb674381c25f084b1600afd9680
MD5 0169325a3543a186c6a5f9214cd9ac7a
BLAKE2b-256 8287faa3bef0646f0ec651ff1bf52737f37bfafde18f63edcb807836858e59c5

See more details on using hashes here.

File details

Details for the file pyviewfactor-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyviewfactor-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pyviewfactor-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4670322cd8ba7e2953c3064de1124f1864b38871664cb9860fecb6d9787decbe
MD5 df551cb2d3f4741c71e4a17f7af53c53
BLAKE2b-256 46446bd8f0d119ff03f30684a04e9a2ac47beadc5156cc4e2008de4b18b8ebc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page