# ClimateStudio pass-like simulation workflow

Having nothing to do over the weekend, I wanted to see if I can reproduce ClimateStudio’s pass-like simulation workflow in vanilla Radiance.

Folks at Solemma came up with this path-tracing “pass” style workflow. Not only it’s fast, but it’s also a great way to communicate the ray-tracing process to the end-users. Having been inspired by that, I was wondering if I can recreate that workflow using existing tools with vanilla Radiance.

Specifically, I was using Numpy in Python Jupyter lab environment. Numpy is a python library that wraps the BLAS linear algebra library written in C and Fortran. As a result, Numpy is fast for matrix multiplication, which comes in very handy with Radiance matrix-based simulation. I’ve written some routines for loading and doing matrix multiplication in Numpy in frads. Running Python in Jupyter Lab allows us to store the loaded matrix files for later use so that we can multiply matrices quickly for each pass.

The rest of the workflow is then very simple:

1. gather the octree
2. gather the input grid sensor
3. load an annual sky-matrix into memory
4. call rcontrib to generate a sensor-to-sky matrix
5. multiply the sensor-to-sky matrix with the preloaded sky-matrix
6. Figure out the sDA, e.g. what percentage of the year a sensor is > 300 lx, .etc.
7. Plot our sDA results.
8. Repeat another run starting at step 4, compute the cumulated average sDA from previous runs and plot the cumulative average.

Here I have a simple open office model with 460 workplane sensors. The results look like this (this .gif should be in real-time with each pass takes a little over a second). Instead of having ambient division (`ad`) set to 1 to mimic pass-tracing, I set it to 64 since the initial ray generation relies on `ad` as well. There may be a better way to generate the initial rays with something like `rsensor`.

The entire code is available here if you are interested. You can also try the script with your own model.
Let me know if you have any feedback or questions.

6 Likes

Wow, Taoning – your weekend was much more productive than mine! (My weekend was spent recovering from a stomach bug I picked up on a family vacation the week prior.)

I don’t know if you took advantage of rcontrib’s built-in accumulation function, which can create a progressive total with the -c 0 option (with -r in subsequent runs). It might save a little time, especially if you use a binary matrix format (float or double).

In any case, this is brilliant!
-Greg

Thanks, Greg. I forgot about the `-r` option in `rcontrib`. Although, I don’t know how to use the progressive total with `-c 0`. It would give me a single row matrix? But I need a full record for multiplying with the sky matrix? Do I first run with `-c 1` and then `-c 0 -r` with subsequent runs?

Oh, you’re right. I don’t think it works in this case due to the single-record output with -c 0. You would have to have a separate rcontrib refinement loop for each measurement position/direction, rereading and adding to the total for just one row, then stacking rows into a matrix. Not any more efficient than the way you’re doing it, I don’t think.

Looks like Milan Broquet achieved something similar, according to this post

1 Like