Running Python code for light simulation

Hi,
I am not an architect but using your nice simulation tool for a research project, so I do not have an actual layout but having a python layout showing rooms, their sizes, and orientation. What I want to do is run a lighting simulation for my python layout (not Rhinio or cad).

So I found this code online which enables me to use my python layout to run a simple light simulation (example is shown for one room). My problem is that in this code nothing is linking the generated room with the actual address, and also there is no option to pull up the weather data for a specific region. Can you help me know what should be added to this code to enable me pull up the weather data for the area where my layout is located?

Thank you!

from honeybee.room import Room
from honeybee.radiance.material.glass import Glass
from honeybee.radiance.sky.certainIlluminance import CertainIlluminanceLevel
from honeybee.radiance.recipe.pointintime.gridbased import GridBased

# create a test room
room = Room(origin=(0, 0, 3.2), width=4.2, depth=6, height=3.2,
            rotation_angle=45)

# add fenestration
#  # add a window to the back wall
room.add_fenestration_surface(wall_name='back', width=2, height=2, sill_height=0.7)

# add another window with custom material. This time to the right wall
glass_60 = Glass.by_single_trans_value('tvis_0.6', 0.6)
room.add_fenestration_surface('right', 4, 1.5, 1.2, radiance_material=glass_60)

# run a grid-based analysis for this room
# generate the sky
sky = CertainIlluminanceLevel(illuminance_value=2000)

# generate grid of test points
analysis_grid = room.generate_test_points(grid_size=0.5, height=0.75)

# put the recipe together
rp = GridBased(sky=sky, analysis_grids=(analysis_grid,), simulation_type=0,
               hb_objects=(room,))

# write and run the analysis
batch_file = rp.write(target_folder=r'c:\ladybug', project_name='room')
rp.run(batch_file, debug=False)

# results - in this case it will be an analysis grid
result = rp.results()[0]

# print the values for each point
for value in result.combined_value_by_id():
    print('illuminance value: %d lux' % value[0])

Hi,@fhalawa1 If you want to do light simulation, you should reference this website
https://www.ladybug.tools/apidoc/honeybee/honeybee.html

Which function gets me the lighting data? Are there examples any where?

The sample file is running the simulation with an overcast sky which is not taking location into consideration. That’s why the sky is generated with CertainIlluminanceLevel.

sky = CertainIlluminanceLevel(illuminance_value=2000)

It depends on the type of the study but if you are looking for a point-in-time simulation then you should use climate-based sky instead:

https://www.ladybug.tools/apidoc/honeybee/honeybee.radiance.sky.html#module-honeybee.radiance.sky.climatebased

To pass weather data you can use from_wea classmethod: honeybee.radiance.sky package — Honeybee 0.0.04 documentation

from ladybug.wea import Wea
from honeybee.radiance.sky.climatebased import ClimateBased

epw_file = 'PATH TO EPW FILE'
wea = Wea.from_epw_file(epw_file)
sky = ClimateBased(wea, month=6, day=21, hour=12)

# the rest of the code is pretty much the same
# ...

NOTE: I’m using a newer version of honeybee with breaking changes and didn’t test this code but it should at least give you an idea where to start.

Thanks, so this answers my questions regarding pulling location + weather data.

My main challenge now is how to calculate lighting for a specific layout instead of a specific room… The issues are 1) Light passes through windows of the layout, 2) rooms have walls, and the walls may hinder the light from passing, right? How can I avoid this? Here is a schematic

Replied to your questions here:

I’m closing this topic to avoid duplication.