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 at arep-dev.gitlab.io/pyViewFactor.

Urban View Factor

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

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 via the SA-30 semi-analytic kernel — handles touching and coplanar faces analytically, no epsilon shift
    • 👁️ Visibility checks based on face orientation
    • 🚧 Obstruction detection using Möller–Trumbore ray-triangle intersection, BVH-accelerated (O(log N) per ray)
    • ⚙️ Strict / non-strict modes for robustness control
    • ⚡ Full N×N view-factor matrix with Numba prange parallelism (~33× faster than v1.0)
    • 📦 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] numba is optional but strongly recommended. Without it, all kernels fall back to sequential pure-Python with identical results — no need to pin an older version.

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 want to import your own geometry from a different format? (*.dat, *.idf, *.stl, ...)

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/

The documentation includes:

  • Theory: view factor integral, SA-30 semi-analytic kernel, BVH obstruction engine,
  • Implementation: architecture, visibility & obstruction semantics, performance guide,
  • Extended examples with analytical validations.

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,
  author       = "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.1.0.tar.gz (35.4 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.1.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyviewfactor-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fc00f7f89aa4418366bf28b113c1fbe9551eebdd270361b0fc7cc62aef8973d1
MD5 a3315b1079105655ce7b5afaca35624c
BLAKE2b-256 be7babaac1a2cf0cda13ffec9285443cf501e13384933ab78be594edbe96b39b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyviewfactor-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26730c72b912207b360f74038a22f6a7b7efc59348019515ab58340358d5db92
MD5 3d60ee4105b83dd66229c336f6509fcd
BLAKE2b-256 fa2be072bb410c83cca6304dd0bcbded6329d7a83fb174b370fd950b6f16bcf7

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