krzysztofarendt / building3d

Towards 3D building modeling and simulation
MIT License
20 stars 2 forks source link

Unit tests

Building3D

A wannabe framework for 3D modeling and simulation of buildings—trying its best to unify sound, heat, light, and more under one roof (pun intended).

About

The long-term goal of this project is to develop a unified environment for the simulation of various phenomena in buildings, including:

All these simulation types require buildings to be represented as 3D polygons, so why not have a single tool for all of them?

In the past, I worked with some simulation software for these kinds of analyses, and my impression was that the landscape is very fragmented. Some tools have a very inflexible design due to their long development histories, while others focus solely on one aspect (e.g., only lighting, only sound), even though many of these fields share common foundations (e.g., both sound and lighting require ray tracing). Tools with GUIs are often outdated, while those without a GUI force you to write models in some highly specific language or format you’ll need to learn just for that tool. If you come across a software suite that supports multiple types of analyses, it’s often a patchwork of open-source engines glued together through hard-to-maintain interfaces. On top of that, many tools are proprietary.

I think it would be great to have a common base code for these simulation types. This base could cover:

For this base code to be adopted by others, the following supplementary goals must be met:

The goal I’ve set is too ambitious for one person. More realistically, I’ll focus on building the foundation and creating some simple demos for each simulation type.

I chose Python because:

Please note that, at the moment, this is just a hobby project that I work on in my limited free time. Given the scope I’ve outlined, there’s a high chance it may never reach full maturity. However, I’ll aim to document the modules I believe are already useful.

Lastly, feel free to contact me if you think of an application where this project could be useful.

Status

What's kind of ready:

What's next in the pipeline:

Examples

Below are the examples of ray tracing simulations. They are not usable yet - just looking pretty.

Cubes

Sphere

Teapot

Please check out the example scripts in examples/.

This projects heavily relies on Numba and most of the geometry functions are JIT-compiled, which takes up to 1-2 minutes, depending which example you run.

Short scripts (everything without ray or auralize in its name) can be run without JIT:

NUMBA_DISABLE_JIT=1 python examples/building_example.py

Installation

Currently, the package on PyPi is not kept up to date (but I reserved the spot;), so it's best to clone this repository and install with pip:

python3.10 -m venv venv
source venv/bin/activate
pip install -e .[dev]

Optional dependencies:

sudo apt install cloc  # for source code line counting

Testing

Please note that the package has been tested only on Linux!

Run unit tests:

make test

Produce a coverage report:

make coverage

Documentation

Most of the modules are documented via docstrings. There is no real documentation yet, because things are still moving fast.

Anyway, to give you some idea of the concept I used for the geometry definition, here's the outline:

Each object (polygon, wall, solid, zone, building) has a name which doesn't have to be globally unique, but needs to be locally unique (e.g. 2 walls within a single solid must have different names, but 2 walls from different solids can be named same).

Objects can be accessed in two ways:

At the moment the geometry can be defined by:


My scratchpad

Loose ideas, to be or not to be implemented, in no particular order:

Other cool projects:

Commercial software:

Might be useful for the validation of sound simulation:

Open datasets: