Skip to content

Commit

Permalink
feat(dynamic): Expose dynamic shade transmittance
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Apr 23, 2022
1 parent a428721 commit 4ea6cbd
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 9 deletions.
2 changes: 1 addition & 1 deletion extras-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pollination-honeybee-vtk==0.4.2
pollination-honeybee-vtk==0.4.3
16 changes: 16 additions & 0 deletions pollination/pmv_comfort_map/_comfort.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ class ComfortMappingEntryPoint(DAG):
optional=True
)

transmittance_contribs = Inputs.folder(
description='An optional folder containing a transmittance schedule JSON '
'and sub-folders of irradiance results that exclude the shade from the '
'calculation. There should be one sub-folder per window groups and each '
'one should contain three .ill files named direct.ill, indirect.ill and '
'reflected.ill. If specified, these will be added to the irradiance inputs '
'before computing shortwave MRT deltas.', optional=True
)

trans_schedules = Inputs.file(
description='A schedule JSON that contains fractional schedule values '
'for each shade transmittance schedule in the model.'
)

occ_schedules = Inputs.file(
description='A JSON file containing occupancy schedules derived from '
'the input model.'
Expand Down Expand Up @@ -145,6 +159,8 @@ def create_shortwave_mrt_map(
ref_irradiance=ref_irradiance,
sun_up_hours=sun_up_hours,
contributions=contributions,
transmittance_contribs=transmittance_contribs,
trans_schedules=trans_schedules,
solarcal_par=solarcal_parameters,
run_period=run_period,
name=grid_name
Expand Down
98 changes: 98 additions & 0 deletions pollination/pmv_comfort_map/_dynshade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
from pollination_dsl.dag import Inputs, DAG, task
from dataclasses import dataclass
from typing import Dict, List

from pollination.path.read import ReadJSONList

from ._shdcontrib import ShadeContribEntryPoint


@dataclass
class DynamicShadeContribEntryPoint(DAG):
"""Entry point for computing the contributions from dynamic windows."""

# inputs
radiance_parameters = Inputs.str(
description='Radiance parameters for ray tracing.',
default='-ab 2 -ad 5000 -lw 2e-05',
)

octree_file = Inputs.file(
description='A Radiance octree file with a completely transparent version '
'of the dynamic shade group.', extensions=['oct']
)

octree_file_with_suns = Inputs.file(
description='A Radiance octree file with sun modifiers.',
extensions=['oct']
)

group_name = Inputs.str(
description='Name for the dynamic aperture group being simulated.'
)

sensor_grid_folder = Inputs.folder(
description='A folder containing all of the split sensor grids in the model.'
)

sensor_grids = Inputs.file(
description='A JSON file with information about sensor grids to loop over.'
)

sky_dome = Inputs.file(
description='Path to sky dome file.'
)

sky_matrix = Inputs.file(
description='Path to total sky matrix file.'
)

sky_matrix_direct = Inputs.file(
description='Path to direct skymtx file (gendaymtx -d).'
)

sun_modifiers = Inputs.file(
description='A file with sun modifiers.'
)

sun_up_hours = Inputs.file(
description='A sun-up-hours.txt file output by Radiance and aligns with the '
'input irradiance files.'
)

@task(template=ReadJSONList)
def read_grids(self, src=sensor_grids) -> List[Dict]:
return [
{
'from': ReadJSONList()._outputs.data,
'description': 'Sensor grids information.'
}
]

@task(
template=ShadeContribEntryPoint,
needs=[read_grids],
loop=read_grids._outputs.data,
sub_folder='shortwave',
sub_paths={
'sensor_grid': '{{item.full_id}}.pts',
'ref_sensor_grid': '{{item.full_id}}_ref.pts',
}
)
def run_radiance_shade_contrib(
self,
radiance_parameters=radiance_parameters,
octree_file=octree_file,
octree_file_with_suns=octree_file_with_suns,
group_name=group_name,
grid_name='{{item.full_id}}',
sensor_grid=sensor_grid_folder,
ref_sensor_grid=sensor_grid_folder,
sensor_count='{{item.count}}',
sky_dome=sky_dome,
sky_matrix=sky_matrix,
sky_matrix_direct=sky_matrix,
sun_modifiers=sun_modifiers,
sun_up_hours=sun_up_hours
) -> List[Dict]:
pass
175 changes: 175 additions & 0 deletions pollination/pmv_comfort_map/_shdcontrib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
from pollination_dsl.dag import Inputs, DAG, task
from dataclasses import dataclass

from pollination.honeybee_radiance.contrib import DaylightContribution
from pollination.honeybee_radiance.coefficient import DaylightCoefficient
from pollination.honeybee_radiance.sky import SubtractSkyMatrix


@dataclass
class ShadeContribEntryPoint(DAG):
"""Entry point for Radiance calculations for comfort mapping."""

# inputs
radiance_parameters = Inputs.str(
description='Radiance parameters for ray tracing.',
default='-ab 2 -ad 5000 -lw 2e-05',
)

octree_file = Inputs.file(
description='A Radiance octree file with a completely transparent version '
'of the dynamic shade group.', extensions=['oct']
)

octree_file_with_suns = Inputs.file(
description='A Radiance octree file with sun modifiers.',
extensions=['oct']
)

group_name = Inputs.str(
description='Name for the dynamic aperture group being simulated.'
)

grid_name = Inputs.str(
description='Sensor grid file name (used to name the final result files).'
)

sensor_grid = Inputs.file(
description='Sensor grid file.',
extensions=['pts']
)

ref_sensor_grid = Inputs.file(
description='Reflected Sensor grid file.',
extensions=['pts']
)

sensor_count = Inputs.int(
description='Number of sensors in the input sensor grid.'
)

sky_dome = Inputs.file(
description='Path to sky dome file.'
)

sky_matrix = Inputs.file(
description='Path to total sky matrix file.'
)

sky_matrix_direct = Inputs.file(
description='Path to direct skymtx file (gendaymtx -d).'
)

sun_modifiers = Inputs.file(
description='A file with sun modifiers.'
)

sun_up_hours = Inputs.file(
description='A sun-up-hours.txt file output by Radiance and aligns with the '
'input irradiance files.'
)

@task(template=DaylightContribution)
def direct_sun_shade_group(
self,
grid=grid_name,
group=group_name,
radiance_parameters=radiance_parameters,
fixed_radiance_parameters='-aa 0.0 -I -ab 0 -dc 1.0 -dt 0.0 -dj 0.0 -dr 0',
sensor_count=sensor_count,
modifiers=sun_modifiers,
sensor_grid=sensor_grid,
conversion='0.265 0.670 0.065',
output_format='a', # make it ascii so we expose the file as a separate output
header='remove', # remove header to make it process-able later
scene_file=octree_file_with_suns
):
return [
{
'from': DaylightContribution()._outputs.result_file,
'to': 'shd_trans/final/{{self.grid}}/{{self.group}}/direct.ill'
}
]

@task(template=DaylightCoefficient)
def direct_sky_shade_group(
self,
grid=grid_name,
group=group_name,
radiance_parameters=radiance_parameters,
fixed_radiance_parameters='-aa 0.0 -I -ab 1 -c 1 -faf',
sensor_count=sensor_count,
sky_matrix=sky_matrix_direct,
sky_dome=sky_dome,
sensor_grid=sensor_grid,
conversion='0.265 0.670 0.065', # divide by 179
scene_file=octree_file
):
return [
{
'from': DaylightCoefficient()._outputs.result_file,
'to': 'shd_trans/initial/{{self.group}}/direct_sky/{{self.grid}}.ill'
}
]

@task(template=DaylightCoefficient)
def total_sky_spec_shade_group(
self,
grid=grid_name,
group=group_name,
radiance_parameters=radiance_parameters,
fixed_radiance_parameters='-aa 0.0 -I -c 1 -faf',
sensor_count=sensor_count,
sky_matrix=sky_matrix,
sky_dome=sky_dome,
sensor_grid=sensor_grid,
conversion='0.265 0.670 0.065', # divide by 179
scene_file=octree_file
):
return [
{
'from': DaylightCoefficient()._outputs.result_file,
'to': 'shd_trans/initial/{{self.group}}/total_sky/{{self.grid}}.ill'
}
]

@task(
template=SubtractSkyMatrix,
needs=[total_sky_spec_shade_group, direct_sky_shade_group]
)
def output_matrix_math_shade_group(
self,
grid=grid_name,
group=group_name,
total_sky_matrix=total_sky_spec_shade_group._outputs.result_file,
direct_sky_matrix=direct_sky_shade_group._outputs.result_file
):
return [
{
'from': SubtractSkyMatrix()._outputs.results_file,
'to': 'shd_trans/final/{{self.grid}}/{{self.group}}/indirect.ill'
}
]

@task(template=DaylightCoefficient)
def ground_reflected_sky_shade_group(
self,
grid=grid_name,
group=group_name,
radiance_parameters=radiance_parameters,
fixed_radiance_parameters='-aa 0.0 -I -c 1',
sensor_count=sensor_count,
sky_matrix=sky_matrix,
sky_dome=sky_dome,
sensor_grid=ref_sensor_grid,
conversion='0.265 0.670 0.065', # divide by 179
output_format='a', # make it ascii so we expose the file as a separate output
header='remove', # remove header to make it process-able later
scene_file=octree_file
):
return [
{
'from': DaylightCoefficient()._outputs.result_file,
'to': 'shd_trans/final/{{self.grid}}/{{self.group}}/reflected.ill'
}
]
Loading

0 comments on commit 4ea6cbd

Please sign in to comment.