Skip to content

Commit

Permalink
Merge pull request #54 from LBNL-ETA/genroom
Browse files Browse the repository at this point in the history
Genroom
  • Loading branch information
taoning authored Feb 29, 2024
2 parents 1ee9107 + 62236b1 commit 1f9af7a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/how-to/guide_rad1.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ The code block demonstrates how we generate a grid of sensors with
1 meter spacing and 0.75 meters away from the floor:

```py
floor_primitives = fr.unpack_primitive("Objects/floor_aroom.rad")
floor_primitives = fr.unpack_primitives("Objects/floor_aroom.rad")
# Since we only have one primitive in this file,
# we'll take the first one to parse.
floor_polygon = fr.parse_polygon(floor_primitives[0])
Expand Down
11 changes: 3 additions & 8 deletions frads/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ class ShadingGeometryConfig:
shading_geometry_file: Union[str, Path] = ""
shading_geometry_bytes: Optional[np.ndarray] = None

def __post_init__(self):
...
def __post_init__(self): ...


@dataclass
Expand Down Expand Up @@ -502,6 +501,7 @@ def __post_init__(self):
f"{k} matrix name {v.matrix_name} not found in materials"
)


@dataclass
class WorkflowConfig:
"""Workflow configuration dataclass.
Expand Down Expand Up @@ -598,13 +598,8 @@ def __init__(self, config: WorkflowConfig):
view.view, xres=view.xres, yres=view.yres
)
for name, surface in self.config.model.surfaces.items():
polygons = [parse_polygon(p) for p in surface.primitives]
flipped_primitives = [
polygon_primitive(p.flip(), s.modifier, s.identifier)
for p, s in zip(polygons, surface.primitives)
]
self.surface_senders[name] = SurfaceSender(
surfaces=flipped_primitives,
surfaces=surface.primitives,
basis=surface.basis,
)

Expand Down
43 changes: 23 additions & 20 deletions frads/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from frads import utils
import numpy as np


@dataclass
class WindowSurface:
polygon: Polygon
Expand All @@ -23,7 +24,6 @@ class Surface:
identifier: str
primitives: List[pr.Primitive]


def move_window(self, distance: float) -> None:
"""Move windows in its normal direction."""
direction = self.base.normal * distance
Expand All @@ -48,7 +48,9 @@ def rotate_z(self, radians):
modifier=self.base_primitive.modifier,
identifier=self.base_primitive.identifier,
)
new_polygons = [plg.rotate(center, zaxis, radians) for plg in self.polygons]
new_polygons = [
plg.rotate(center, zaxis, radians) for plg in self.polygons
]
new_primitives = []
for idx, polygon in enumerate(new_polygons):
new_primitives.append(
Expand All @@ -75,8 +77,6 @@ def rotate_z(self, radians):
self.base_primitive = new_base_primitive




@dataclass
class Room:
floor: Surface
Expand Down Expand Up @@ -106,11 +106,14 @@ def window_primitives(self) -> List[pr.Primitive]:
*[srf.primitive for srf in self.wwall.windows],
]


def model_dump(self) -> dict:
model = {}
model["materials"] = {"bytes": b" ".join(p.bytes for p in self.materials)}
model["scene"] = {"bytes": b" ".join(p.bytes for p in self.primitives())}
model["materials"] = {
"bytes": b" ".join(p.bytes for p in self.materials)
}
model["scene"] = {
"bytes": b" ".join(p.bytes for p in self.primitives())
}
model["windows"] = {}
for primitive in self.window_primitives():
model["windows"][primitive.identifier] = {"bytes": primitive.bytes}
Expand All @@ -133,7 +136,6 @@ def rotate_z(self, radians):
self.wwall.rotate_z(radians)
self.nwall.rotate_z(radians)


def validate(self) -> None:
"""Validate the room model."""
material_names = [p.identifier for p in self.materials]
Expand Down Expand Up @@ -163,7 +165,7 @@ def make_window(
dist_left: float,
dist_bot: float,
width: float,
height: float
height: float,
) -> Tuple[Polygon, WindowSurface]:
"""Make one or more window and punch a hole.
Expand Down Expand Up @@ -199,13 +201,11 @@ def make_window(
polygon=window_polygon,
modifier="glass_60",
identifier=name,
)
),
)

def make_window_wwr(
base: Polygon,
wwr: float
) -> Tuple[Polygon, WindowSurface]:

def make_window_wwr(base: Polygon, wwr: float) -> Tuple[Polygon, WindowSurface]:
"""
Make a single window and punch a hole based on window-to-wall ratio.
Expand All @@ -218,7 +218,7 @@ def make_window_wwr(
polygon=window_polygon,
modifier="glass_60",
identifier="void",
)
),
)


Expand Down Expand Up @@ -306,13 +306,16 @@ def create_south_facing_room(
) -> Room:
materials = list(utils.material_lib().values())
pt1 = np.array((0, 0, 0))
pt2 = pt1 + np.array((width, 0, 0))
pt3 = pt2 + np.array((0, depth, 0))
pt2 = pt1 + np.array((0, depth, 0))
pt3 = pt2 + np.array((width, 0, 0))
base_floor = Polygon.rectangle3pts(pt1, pt2, pt3)
_, base_ceiling, base_swall, base_ewall, base_nwall, base_wwall = base_floor.extrude(
np.array((0, 0, floor_floor))
_, base_ceiling, base_wwall, base_nwall, base_ewall, base_swall = (
base_floor.extrude(np.array((0, 0, floor_floor)))
)
base_ceiling = base_ceiling.flip()
base_ceiling = base_ceiling.move(
np.array((0, 0, floor_ceiling - floor_floor))
)
base_ceiling = base_ceiling.move(np.array((0, 0, floor_ceiling - floor_floor)))
floor = create_surface(
base_floor,
modifier="neutral_lambertian_0.2",
Expand Down

0 comments on commit 1f9af7a

Please sign in to comment.