pyviewfactor 0.1.8__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. pyviewfactor-0.1.11/PKG-INFO +487 -0
  2. pyviewfactor-0.1.11/README.md +466 -0
  3. pyviewfactor-0.1.11/pyviewfactor/11pyviewfactor.py +1166 -0
  4. pyviewfactor-0.1.11/pyviewfactor/OLD.py +984 -0
  5. pyviewfactor-0.1.11/pyviewfactor/_version.py +5 -0
  6. pyviewfactor-0.1.11/pyviewfactor/pyviewfactor.py +1341 -0
  7. pyviewfactor-0.1.11/pyviewfactor/pyviewfactor_906.py +1647 -0
  8. pyviewfactor-0.1.8/pyviewfactor/pyviewfactor.py → pyviewfactor-0.1.11/pyviewfactor/pyviewfactor_v1.py +235 -38
  9. pyviewfactor-0.1.11/pyviewfactor/pyviewfactor_vis_obs_OK.py +1206 -0
  10. pyviewfactor-0.1.11/pyviewfactor/pyviewfactorv2.py +1719 -0
  11. pyviewfactor-0.1.11/pyviewfactor.egg-info/PKG-INFO +487 -0
  12. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/pyviewfactor.egg-info/SOURCES.txt +6 -0
  13. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/setup.cfg +1 -2
  14. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/test/test_view_factor.py +1 -0
  15. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/test/test_visibility_obstruction.py +80 -0
  16. pyviewfactor-0.1.8/PKG-INFO +0 -376
  17. pyviewfactor-0.1.8/README.md +0 -355
  18. pyviewfactor-0.1.8/pyviewfactor/_version.py +0 -5
  19. pyviewfactor-0.1.8/pyviewfactor.egg-info/PKG-INFO +0 -376
  20. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/LICENSE.txt +0 -0
  21. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/pyviewfactor/__init__.py +0 -0
  22. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/pyviewfactor.egg-info/dependency_links.txt +0 -0
  23. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/pyviewfactor.egg-info/requires.txt +0 -0
  24. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/pyviewfactor.egg-info/top_level.txt +0 -0
  25. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/setup.py +0 -0
  26. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/test/__init__.py +0 -0
  27. {pyviewfactor-0.1.8 → pyviewfactor-0.1.11}/test/test_utils.py +0 -0
@@ -0,0 +1,487 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyviewfactor
3
+ Version: 0.1.11
4
+ Summary: A python library to calculate numerically exact radiation view factors between planar faces.
5
+ Home-page: https://gitlab.com/arep-dev/pyViewFactor/
6
+ Author: Mateusz BOGDAN, Edouard WALTHER, Marc ALECIAN, Mina CHAPON
7
+ Author-email: mateusz.bogdan@arep.fr
8
+ License: MIT
9
+ Keywords: radiative-transfer,radiation,vtk,geometry,viewfactor,visibility
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Topic :: Scientific/Engineering :: Physics
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.txt
17
+ Requires-Dist: numpy>=1.19
18
+ Requires-Dist: scipy>=1.7
19
+ Requires-Dist: numba>=0.55
20
+ Requires-Dist: pyvista>=0.32
21
+
22
+ # PyViewFactor
23
+
24
+ > `pyViewFactor` is a lightweight open-source Python library for exact view-factor computations on polygonal meshes.
25
+
26
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/3d40d1804eccbaefbc8b1736ff30d0d9f08141ad/img/FF_sceneUrbaine_cyl_RT.png" alt="Urban View Factor" width="800" />
27
+
28
+
29
+ [![Latest Release](https://gitlab.com/arep-dev/pyViewFactor/-/badges/release.svg)](https://gitlab.com/arep-dev/pyViewFactor/-/releases)
30
+ [![pipeline status](https://gitlab.com/arep-dev/pyViewFactor/badges/main/pipeline.svg)](https://gitlab.com/arep-dev/pyViewFactor/pipelines)
31
+ [![codecov](https://codecov.io/gl/arep-dev/pyViewFactor/graph/badge.svg?token=HPHU835UZ8)](https://codecov.io/gl/arep-dev/pyViewFactor)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
+ [![Pypi Version](https://img.shields.io/pypi/v/pyviewfactor)](https://pypi.org/project/pyviewfactor/)
34
+ [![Pypi Downloads](https://img.shields.io/pypi/dm/pyviewfactor.svg?label=pypi%20downloads)](https://pypi.org/project/pyviewfactor/)
35
+
36
+ *Documentation available [here](https://arep-dev.gitlab.io/pyViewFactor/).*
37
+
38
+ ## Table of Contents
39
+
40
+ 1. [Features](#features)
41
+ 2. [Quick Start](#quick-start)
42
+ 3. [More Examples](#more-examples)
43
+ 4. [Installation](#installation)
44
+ 5. [Citation & Acknowledgments](#citation--acknowledgments)
45
+ 6. [License](#license)
46
+
47
+
48
+ ## Features
49
+
50
+ * This library enables the computation of radiation view factors between palanar polygons using an **accurate** double‐contour integration method described in
51
+ [(Mazumder and Ravishankar 2012)](https://www.academia.edu/download/77459051/Viewfactor_paper_IJHMT.pdf)
52
+ with insights from [(Schmid 2016)](https://hal.archives-ouvertes.fr/tel-01734545/).
53
+ * It uses the handy [`Pyvista`](https://docs.pyvista.org/) package to deal with geometry imports (`*.stl`, `*.vtk`, `*.obj`, ...),
54
+ geometry creations, and some other mesh functionallities under the hood,
55
+ * For a given geometry or set of planar faces, with `pyViewFactor` you will able to :
56
+ [x] Optionally check that the faces can "see" each other with `get_visibility(face1, face2, ...)`,
57
+ [x] Optionally check that no obstruction lies between them with `get_obstruction(face1, face2, obstacle, ...)`,
58
+ [x] Compute the view factor from `face2` to `face1` with `compute_view_factor(face1, face2, ...)`,
59
+ [x] Compute the view factor matrix for a complete mesh, in parallel 🚀, with `compute_viewfactor_matrix(mesh, ...)`!
60
+
61
+
62
+ > [!NOTE]
63
+ > All the examples below are provided as `*.py` files in the [`/examples/` folder](https://gitlab.com/arep-dev/pyViewFactor/-/tree/main/examples) of the repository, with additional usecases.
64
+
65
+
66
+ ## Quick Start
67
+
68
+ Suppose we want to compute the radiation view factor between a triangle
69
+ and a rectangle facing each other:
70
+
71
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/mwe.png" alt="Triangle and rectangle configuration" width="260"/>
72
+
73
+ You are few lines of code away from your first view factor computation:
74
+
75
+ ```python
76
+ import pyvista as pv
77
+ import pyviewfactor as pvf
78
+
79
+ # Create a rectangle and a triangle facing each other
80
+ pointa1 = [0.0, 0.0, 0.0]
81
+ pointb1 = [1.0, 0.0, 0.0]
82
+ pointc1 = [0.0, 1.0, 0.0]
83
+ rectangle = pv.Rectangle([pointa1, pointb1, pointc1])
84
+
85
+ pointa2 = [0.0, 0.0, 1.0]
86
+ pointb2 = [0.0, 1.0, 1.0]
87
+ pointc2 = [1.0, 1.0, 1.0]
88
+ triangle = pv.Triangle([pointa2, pointb2, pointc2])
89
+
90
+ if get_visibility(rectangle, triangle):
91
+ F = compute_viewfactor(triangle, rectangle)
92
+ print("VF from rectangle to triangle :", F)
93
+ else:
94
+ print("Not facing each other")
95
+
96
+ pl = pv.Plotter()
97
+ pl.add_mesh(rectangle, color="lightblue", opacity=0.7)
98
+ pl.add_mesh(triangle, color="salmon", opacity=0.7)
99
+
100
+ # compute and glyph normals for mesh1
101
+ n1 = rectangle.compute_normals(cell_normals=True, point_normals=False)
102
+ arrows1 = n1.glyph(orient="Normals", factor=0.1)
103
+ pl.add_mesh(arrows1, color="blue")
104
+ # similarly for mesh2
105
+ n2 = triangle.compute_normals(cell_normals=True, point_normals=False)
106
+ arrows2 = n2.glyph(orient="Normals", factor=0.1)
107
+ pl.add_mesh(arrows2, color="darkred")
108
+
109
+ pl.show()
110
+ ```
111
+
112
+ You usually get your geometry from a different format?
113
+ (`*.dat`, `*.idf`, ...)
114
+
115
+ Check pyvista's documentation on [how to generate a PolyData facet from points](https://docs.pyvista.org/examples/00-load/create-poly.html).
116
+
117
+ ## More Examples
118
+
119
+ ### Example with a closed geometry and the VTK file format
120
+
121
+ We will now compute the view factors within a more complex geometry: a closed sphere
122
+ (clipped in half below), with inwards facing normals, so the faces can "see" each other.
123
+ *Note that the face-to-face visibility is unobstructed (for obstructed geometries,
124
+ see next section).*
125
+
126
+ The field of view factors from one facet to all others will be computed and stored in
127
+ a `.vtk` file, which you can explore with the open source
128
+ [Paraview software](https://www.paraview.org/download/).
129
+
130
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/demi_sphere.png" alt="Sphere" width="350"/>
131
+
132
+ The following snippet can be reused as a kick-start for your own purposes:
133
+ ```python
134
+ import pyvista as pv
135
+ import numpy as np
136
+ import pyviewfactor as pvf
137
+
138
+ sphere = pv.Sphere(radius=10, center=(0, 0, 0), direction=(0, 0, 1),
139
+ theta_resolution=8, phi_resolution=8,
140
+ start_theta=0, end_theta=360,
141
+ start_phi=0, end_phi=180)
142
+ # triangulate
143
+ sphere.triangulate(inplace=True)
144
+ # and put the normals inwards please
145
+ # sphere.flip_faces(inplace=True)
146
+
147
+ # let us chose a cell to compute view factors to
148
+ cell_extracted_id = 2
149
+ # let us chose a cell to compute view factors to
150
+ chosen_face = sphere.extract_cells(cell_extracted_id)
151
+ # convert to PolyData
152
+ chosen_face = pvf.fc_unstruc2poly(chosen_face)
153
+
154
+ # "one array to contain them all"
155
+ F = np.zeros(sphere.n_cells)
156
+ # now let us compute the view factor to all other faces in a sequential way
157
+ for i in range(sphere.n_cells):
158
+ if i != cell_extracted_id:
159
+ face = sphere.extract_cells(i) # other facet
160
+ face = pvf.fc_unstruc2poly(face) # convert to PolyData
161
+ if pvf.get_visibility(face, chosen_face):
162
+ # compute VF
163
+ F[i] = pvf.compute_viewfactor(face,
164
+ chosen_face,
165
+ epsilon=0.00001,
166
+ rounding_decimal=7)
167
+ else:
168
+ print("Problem, all cells should see each other.")
169
+
170
+
171
+ print("Sum check: \n (is Sum_i^n F_i =? 1)", np.sum(F))
172
+
173
+ # put the scalar values in the geometry
174
+ sphere.cell_data["F"] = F
175
+ sphere.save("./sphere.vtk") # ... and save.
176
+
177
+ # let us have a look in 3D with an interactive window...
178
+ pl = pv.Plotter() # instantiate 3D window
179
+ pl.add_mesh(sphere, scalars="VF1", cmap="jet") # add mesh with a nice color scheme
180
+ outline = chosen_face.outline() # gives you just the wireframe of that cell
181
+ pl.add_mesh(
182
+ outline,
183
+ color="red", # pick a contrasting color
184
+ line_width=3.0, # thicker line so it stands out
185
+ pickable=False
186
+ )
187
+ pl.show()
188
+
189
+ # Alternatively, you can compute the full VF matrix rather easily :
190
+ # Computation of the Fij matrix in parallel
191
+ F = pvf.compute_viewfactor_matrix(
192
+ sphere,
193
+ skip_visibility=True,
194
+ skip_obstruction=True,
195
+ compute_kwargs={"epsilon": 1e-4, "rounding_decimal": 8},
196
+ n_jobs=4
197
+ )
198
+
199
+ # We can do the same check as previously for the extracted cell
200
+ print("Sum check: \n (is Sum_i^n F_i =? 1)", cell_extracted_id,
201
+ "=", F[:, cell_extracted_id].sum())
202
+ ```
203
+ The results look as per following images showing the view factor from the chosen cell to all others.
204
+
205
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/F_sphere_clip.png" alt="Clipped result" width="240"/>
206
+
207
+ ### View factors of an individual with a wall
208
+
209
+ For comfort computations, it may be useful to determine heat transfer between an
210
+ invidivual and a wall. We will use here PyVista's
211
+ [doorman example](https://docs.pyvista.org/api/examples/_autosummary/pyvista.examples.downloads.download_doorman.html?highlight=example+man#pyvista.examples.downloads.download_doorman)
212
+ as a basis for the human geometry.
213
+
214
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/Fground.png" alt="View factors of the doorman's faces to the ground" width="380"/>
215
+
216
+ The following code and `.vtk` file of the doorman example are available in
217
+ the [./examples/](https://gitlab.com/arep-dev/pyViewFactor/-/tree/main/examples) folder.
218
+
219
+ ```python
220
+ from tqdm import tqdm
221
+ import numpy as np
222
+ import pyvista as pv
223
+ import pyviewfactor as pvf
224
+
225
+ def fc_Fwall(nom_vtk):
226
+ # This function is bit more generic than this specific use case,
227
+ # so it can be reused for other applications
228
+ mesh = pv.read(nom_vtk)
229
+
230
+ # find all types of walls : in this example only a ground
231
+ wall_types = list(np.unique(mesh["geom_id"]))
232
+ # remove the individual from the list (still named "cylinder"...)
233
+ wall_types.remove("doorman")
234
+ # where is the doorman in the list?
235
+ index_doorman = np.where(mesh["geom_id"] == "doorman")[0]
236
+ # prepare storage for the different walls in a dict
237
+ dict_F = {}
238
+ # loop over wall types
239
+ for type_wall in wall_types:
240
+ # prepare for storing doorman to wall view factor
241
+ F = np.zeros(mesh.n_cells)
242
+ # get the indices of this type of wall
243
+ indices = np.where(mesh["geom_id"] == type_wall)[0]
244
+ # loop over
245
+ for i in indices:
246
+ wall = mesh.extract_cells(i)
247
+ wall = pvf.fc_unstruc2poly(wall) # convert for normals
248
+ # ... for each facet of the individual
249
+ for idx in tqdm(index_doorman):
250
+ face = mesh.extract_cells(idx)
251
+ face = pvf.fc_unstruc2poly(face) # convert for normals
252
+ # check if faces can "see" each other
253
+ if pvf.get_visibility(wall, face):
254
+ # compute face2wall view factor
255
+ Ffp = pvf.compute_viewfactor(wall, face)
256
+ else:
257
+ Ffp = 0
258
+ F[idx] = Ffp
259
+ # store array F in e.g. dict_F["F_ceiling"]
260
+ dict_F["F_" + type_wall.replace("\r", "")] = F
261
+ return dict_F
262
+
263
+ # You can get the doorman geomtry it directly from here:
264
+ # https://gitlab.com/arep-dev/pyViewFactor/-/blob/main/examples/example_doorman_clean.vtk
265
+ # ... or get it from this repository's examples
266
+ file = "./src_data/example_doorman_clean.vtk"
267
+
268
+ # compute the VFs for the doorman to the different wall types in the scene
269
+ dict_F = fc_Fwall(file)
270
+
271
+ # re-read and store
272
+ mesh = pv.read(file)
273
+ # loop over what is in the dictionary of view factors
274
+ for elt in dict_F.keys():
275
+ mesh[elt.replace("\r", "")] = dict_F[elt] # name the field
276
+ mesh.save("./src_data/example_doorman_VFground.vtk") # store in the intial VTK
277
+
278
+ # have a look without paraview with fancy colors
279
+ mesh.plot(cmap="magma_r", lighting=False)
280
+ ```
281
+
282
+ More details and view factors abacuses can be found [here](https://lhypercube.arep.fr/en/confort/calcul-de-la-temperature-radiante/).
283
+
284
+ If you find the computation time a bit lengthy ⌛:
285
+ * You can use the `compute_viewfactor_matrix()` function that leverages `joblib` with a built-in `n_jobs` argument 🚀,
286
+ * More generally, you can learn how to [go parallel here!](https://eddes.github.io/#go-parallel).
287
+
288
+ ### Computing the view factors of a wall in its built environment
289
+
290
+ For building simulation purposes, it may prove to be useful to compute the ground and sky view factors of a given wall, or the view factor of the wall to other walls in the built environment. In following example (available in the [`/examples/` folder](https://gitlab.com/arep-dev/pyViewFactor/-/tree/main/examples)), we compute the view factors of the environment of the purple wall depicted below.
291
+
292
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/9dbd31d124eb898cc5d17913cfc1f010116e2245/img/wall_view_factors.png" alt="View factors in built environment" width="430"/>
293
+
294
+ ```python
295
+
296
+ # Read the geometry
297
+ mesh = pv.read("./src_data/built_envmt.vtk")
298
+ meshpoly = pvf.fc_unstruc2poly(mesh) # convert to polydata for obstruction check
299
+
300
+ # identify who is who
301
+ i_wall = np.where(mesh["wall_names"] == "wall")[0]
302
+ i_sky = np.where(mesh["wall_names"] == "sky")[0]
303
+ i_building1 = np.where(mesh["wall_names"] == "building1")[0]
304
+ i_building2 = np.where(mesh["wall_names"] == "building2")[0]
305
+
306
+ # get the different elements
307
+ wall = mesh.extract_cells(i_wall)
308
+ sky = mesh.extract_cells(i_sky)
309
+ building1 = mesh.extract_cells(i_building1)
310
+ building2 = mesh.extract_cells(i_building2)
311
+
312
+ # convert to polydata
313
+ wall = pvf.fc_unstruc2poly(wall)
314
+
315
+ # Initialize the View Factor
316
+ Fsky = 0
317
+ # for all cells constituting the ensemble
318
+ for patch in tqdm(i_sky):
319
+ sky = mesh.extract_cells(patch) # extract one cell
320
+ sky = pvf.fc_unstruc2poly(sky) # convert to polydata
321
+ if pvf.get_visibility(sky, wall, strict=True):
322
+ if pvf.get_obstruction(sky, wall, meshpoly, strict=True):
323
+ # compute and increment view factor :
324
+ # F_i->(j+k) = F_i->j + F_i->k
325
+ Fsky += pvf.compute_viewfactor(sky, wall)
326
+
327
+ # same for building 1
328
+ Fbuilding1 = 0
329
+ for patch in tqdm(i_building1):
330
+ bldng1 = mesh.extract_cells(patch)
331
+ bldng1 = pvf.fc_unstruc2poly(bldng1)
332
+ if pvf.get_visibility(bldng1, wall):
333
+ if pvf.get_obstruction(bldng1, wall, meshpoly):
334
+ Fbuilding1 += pvf.compute_viewfactor(bldng1, wall)
335
+
336
+ # same for building 2
337
+ Fbuilding2 = 0
338
+ for patch in tqdm(i_building2):
339
+ bldng2 = mesh.extract_cells(patch)
340
+ bldng2 = pvf.fc_unstruc2poly(bldng2)
341
+ if pvf.get_visibility(bldng2, wall):
342
+ if pvf.get_obstruction(bldng2, wall, meshpoly):
343
+ Fbuilding2 += pvf.compute_viewfactor(bldng2, wall)
344
+
345
+ # complementarity implies \sigma F_i = 1 : compute viewfactor to ground
346
+ Fground = 1 - Fbuilding1 - Fbuilding2 - Fsky
347
+
348
+ # Print results
349
+ print("\n-----------------------------")
350
+ print("Wall to Sky view factor:")
351
+ print("\tSky ", round(Fsky, 4))
352
+ print("Wall to Buildings view factors:")
353
+ print("\tBuilding 1 ", round(Fbuilding1, 4))
354
+ print("\tBuilding 2 ", round(Fbuilding2, 4))
355
+ print("Ground view factor:")
356
+ print("\tGround ", round(Fground, 4))
357
+ ```
358
+
359
+ The code yields following view factors :
360
+ ```math
361
+ F_{\text{sky}} = 0.345 \\
362
+ F_{\text{ground}} = 0.373 \\
363
+ F_{\text{building1}} = 0.251 \\
364
+ F_{\text{building2}} = 0.031 \\
365
+ ```
366
+
367
+ ### Understanding the obstruction check function
368
+
369
+ In real life problems, obstacles may well hinder the radiation heat transfer between
370
+ surfaces. We thus provide a function to perform obstruction tests, as per following example.
371
+
372
+ <img src="https://gitlab.com/arep-dev/pyViewFactor/-/raw/b8f6c858db341da00eacb82d7ca3f51c084288b1/img/intersection_simple.png" alt="Obstruction check between rectangles" width="350"/>
373
+
374
+ The code snippet below shows how the function `get_obstruction()` works and allows to understand its usage.
375
+ ```python
376
+ import pyvista as pv
377
+ import pyviewfactor as pvf
378
+
379
+ # let us first create two rectangles
380
+
381
+ pointa = [0.0, 0.0, 0.0]
382
+ pointb = [1.0, 0.0, 0.0]
383
+ pointc = [0.0, 1.0, 0.0]
384
+ rectangle_down = pv.Rectangle([pointa, pointb, pointc])
385
+
386
+ pointa = [0.0, 0.0, 1.0]
387
+ pointb = [0.0, 1.0, 1.0]
388
+ pointc = [1.0, 0.0, 1.0]
389
+ rectangle_up = pv.Rectangle([pointa, pointb, pointc])
390
+
391
+ # a circle will be the obstruction
392
+ z_translation, r = 0.5, 2
393
+ obstacle = pv.Circle(radius=r, resolution=10)
394
+ obstacle.triangulate(inplace=True)
395
+ # we translate the obstruction right between both rectangles
396
+ obstacle.translate([0, 0, z_translation], inplace=True)
397
+ # Define line segment
398
+ start = rectangle_down.cell_centers().points[0]
399
+ stop = rectangle_up.cell_centers().points[0]
400
+ # Perform ray trace
401
+ # points, ind = obstacle.ray_trace(start, stop)
402
+
403
+ # Create geometry to represent ray trace
404
+ ray = pv.Line(start, stop)
405
+
406
+ # Now we can use the get_obtruction function, to check for the obstruction,
407
+ # and see each cell of the obstruction mesh is in the way.
408
+ obstruction_cell = []
409
+ for idx in range(obstacle.n_cells):
410
+ obs = obstacle.get_cell(idx).cast_to_polydata()
411
+ visible = pvf.get_obstruction(rectangle_down, rectangle_up, obs,
412
+ strict=False, print_debug=False)
413
+ if not visible[0]:
414
+ print("Cell {} of the obstactle is in the way of the".format(idx)
415
+ + "centroids of rectangle_up and rectangle_down")
416
+ obstruction_cell.append(idx)
417
+
418
+ obs = obstacle.extract_cells(obstruction_cell)
419
+
420
+ # if any intersection
421
+ if obs.n_cells > 0:
422
+ p = pv.Plotter()
423
+ p.add_mesh(obstacle, show_edges=True, opacity=0.4, color="red",
424
+ lighting=False, label="obstacle")
425
+ p.add_mesh(rectangle_up, color="blue", line_width=5, opacity=0.9,
426
+ label="rect up")
427
+ p.add_mesh(rectangle_down, color="orange", line_width=5, opacity=0.9,
428
+ label="rect down")
429
+ p.add_mesh(ray, color="black", line_width=5, label="ray trace")
430
+ p.add_mesh(obs, show_edges=True, opacity=0.9, color="green", lighting=False,
431
+ label="cell_obstrucion")
432
+ p.add_legend()
433
+ p.show()
434
+ ```
435
+
436
+
437
+ ## Installation
438
+ `pyViewFactor` can be installed from [PyPi](https://pypi.org/project/pyviewfactor/) using `pip` on Python >= 3.10:
439
+ ```shell
440
+ pip install pyviewfactor
441
+ ```
442
+ You can also visit [PyPi](https://pypi.org/project/pyviewfactor/) or
443
+ [Gitlab](https://gitlab.com/arep-dev/pyViewFactor) to download the sources.
444
+
445
+ Requirements:
446
+ ```
447
+ numpy==1.26.4
448
+ pyvista==0.45
449
+ scipy==1.11.4
450
+ numba==0.61.2
451
+ joblib==1.2.0
452
+ tqdm==4.65.0
453
+
454
+ ```
455
+ The code will probably work with lower versions of the required packages, however this has not been tested.
456
+
457
+ > [!NOTE]
458
+ > 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).
459
+
460
+
461
+ ## Citation & Acknowledgments
462
+ * Main contributors:
463
+ * Mateusz BOGDAN,
464
+ * Edouard WALTHER.
465
+ * Acknowledgment: The authors would like to acknowledge *M. Alecian* for his initial work on the quadrature
466
+ code and *M. Chapon* for her contribution to the code validation.
467
+
468
+ There is even a [conference paper](https://www.researchgate.net/publication/360835982_Calcul_des_facteurs_de_forme_entre_polygones_-Application_a_la_thermique_urbaine_et_aux_etudes_de_confort), showing analytical validations.
469
+
470
+ So if you use `pyViewFactor` in your work, please cite:
471
+ > [!IMPORTANT] Citation:
472
+ > 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.
473
+
474
+ Bibtex entry:
475
+ ``` latex
476
+ @inproceedings{pyViewFactor22bogdan,
477
+ authors = "Mateusz BOGDAN and Edouard WALTHER and Marc ALECIAN and Mina CHAPON",
478
+ title = "Calcul des facteurs de forme entre polygones - Application à la thermique urbaine et aux études de confort",
479
+ year = "2022",
480
+ organization = "IBPSA France",
481
+ venue = "Châlons-en-Champagne, France"
482
+ note = "IBPSA France 2022",
483
+ }
484
+ ```
485
+
486
+ ## License
487
+ MIT License - Copyright (c) AREP 2025