Open Didou09 opened 2 years ago
Hi @obrejank , now the Issue653_SoliAngleArbitrary
branch is up-to-date, you can start on it when you feel like it
The code you can work on is in tofu/geom/_GG.pyx
(bottom of the file, routine compute_solid_angle_apertures_unitvectors()
)
I have prepared basci unit tests that are running and you can use then as you make progress to debug. They can be launched in 2 ways: from the terminal or from a python console.
From the terminal (with verbose and debugger option)
$ pytest tofu/tests/tests01_geom/test_02_compute.py -v -x --pdb
From inside a python console:
In [1]: import tofu as tf
In [2]: test = tf.tests.tests01_geom.test_02_compute.Test01_SolidAngles()
In [3]: test.setup()
In [4]: test.test01_solid_angle_apertures()
Thanks for your help!
Framework:
tofu needs to be able to compute efficiently the solid angle subtended:
nd
closed 3d polygons representingnd
detectors (planar)na
closed 3d polygons representingna
successive aperturesnpts
points in spaceThe
nd
closed 3d polygons are:nd
detectors sharing the same aperturesnd = 10 - 1000
The
na
closed 3d polygons are:na
apertures, shared by all detectorsna = 1-10
the
npts
points are:npts = 10^4-6
)It will be necessary, for each observation point, to compute the solid angle subtended by the intersection between all apertures and the detector, for each detector.
Additionally, there should be an option to return not only the solid angle, but also a unit vector pointed from the observation point, towards the center of mass of the intersection polygon (to indicate, for each points, in which main direction are emitted the photons, useful for anisotropic radiation like hard X-rays)
Additionally, a test should be run to check whether an observation point can actually see the intersection polygon by running the ray-tracing routine that can tell whether an obstacle lies on the path (i.e. a structural element, like a PFC).
The branch already exists, the user-interface is almost done and can be found in:
tofu/geom/_comp_solidangles.py
It is thecalc_solidangle_apertures()
routineDon't hesitate to start working on it when you feel ready
Suggestions & code structure:
I will create a new dedicated branch from
devel
calledIssue_SolidAnglesArbitrary
on which I will prepare the basics and you can take over thenI will create the pure-python routine that will serve as entry-point for the user
I will prepare basic unit tests that you can modify / complement as you see fit
The typical loop would look like this (to be discussed based on your expertise):
Code re-use:
test 2
: a visibility test has already been coded by Laura for single-point, called from a cython routine only (inlined)computation 2
: a routine already exists to compute the solid angle subtended by a closed 3d polygon as seen from any pointPossible difficulties / discussion points:
computation 1
: the intersection polygonI am guessing the best is to parallelize the major loop (
loop 1
), because the computation is independent for each point, but you might have a better idea.Priorities:
compute_solid_angle_apertures_unitvectors()
compute_solid_angle_apertures_light()
compute_solid_angle_apertures_visibility()
The last combination (
visibility = True
andreturn_unit_vector=True
) can be handled by re-using the first one and combining it with already-coded visibility checks.Illustrations:
In the example below, we define three arbitrary 3d polygons, the square represents the detector, the other 2 are its associated apertures. The red lines indicate normal vectors.
And after computing the solid angle for all points on a fine sampling of the tokamak volume, we plot the area where the solid angle is non-zero as a grey area. We used visibility = True to detect the fact that the internal wall hides a fraction of the viewing volume of the detector.
This was done in 2014 using a very ill-coded version of the code that I think you should not use (the computation took ~2 days....).