Metadata-Version: 2.4
Name: frads
Version: 2.1.16
Summary: Framework for lighting and energy simulations
Author-email: LBNL <taoningwang@lbl.gov>
License: *** License Agreement ***
        
        
        Framework for Radiance Simulation Control (Frads) Copyright (c) 2019, The
        Regents of the University of California, through Lawrence Berkeley National
        Laboratory (subject to receipt of any required approvals from the U.S.
        Dept. of Energy).  All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        (1) Redistributions of source code must retain the above copyright notice,
        this list of conditions and the following disclaimer.
        
        (2) Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
        
        (3) Neither the name of the University of California, Lawrence Berkeley
        National Laboratory, U.S. Dept. of Energy nor the names of its contributors
        may be used to endorse or promote products derived from this software
        without specific prior written permission.
        
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
        LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        POSSIBILITY OF SUCH DAMAGE.
        
        You are under no obligation whatsoever to provide any bug fixes, patches,
        or upgrades to the features, functionality or performance of the source
        code ("Enhancements") to anyone; however, if you choose to make your
        Enhancements available either publicly, or directly to Lawrence Berkeley
        National Laboratory, without imposing a separate written license agreement
        for such Enhancements, then you hereby grant the following license: a
        non-exclusive, royalty-free perpetual license to install, use, modify,
        prepare derivative works, incorporate into other computer software,
        distribute, and sublicense such enhancements or derivative works thereof,
        in binary and source code form.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.24.4
Requires-Dist: pyradiance==1.2.4
Requires-Dist: pywincalc>=3.1.0
Requires-Dist: pyenergyplus_lbnl==25.2.0
Requires-Dist: scipy>=1.10.1

# frads: Framework for Radiance and EnergyPlus Simulation

[![Install + Test](https://github.com/LBNL-ETA/frads/actions/workflows/main.yml/badge.svg)](https://github.com/LBNL-ETA/frads/actions/workflows/main.yml)
[![PyPI](https://img.shields.io/pypi/v/frads.svg)](https://pypi.org/project/frads/)
[![Downloads](https://img.shields.io/pypi/dm/frads.svg)](https://pypi.org/project/frads/)
[![Python](https://img.shields.io/pypi/pyversions/frads.svg)](https://pypi.org/project/frads/)

`frads` is a Python library for building lighting and energy simulation. It provides high-level abstractions over [Radiance](https://www.radiance-online.org) and [EnergyPlus](https://energyplus.net), automating matrix-based annual daylight simulation workflows and enabling Radiance–EnergyPlus co-simulation.

## Features

- **Matrix-based daylight simulation** — automates 2-phase, 3-phase, and 5-phase Radiance workflows for fast, accurate annual simulations
- **EnergyPlus co-simulation** — couples Radiance illuminance calculations with EnergyPlus at each timestep via the EnergyPlus Python API
- **Complex fenestration systems** — creates and manages BSDF glazing systems (electrochromic, venetian blinds, fabric shades) using [pyWinCalc](https://github.com/LBNL-ETA/pyWinCalc)
- **Dynamic shading control** — implements occupancy-based daylight dimming, glare control, and thermal pre-cooling in a single simulation loop
- **Sky and weather** — parses EPW/WEA files and generates Perez all-weather and CIE sky models

## Installation

```bash
pip install frads
```

All dependencies, including Radiance (via `pyradiance`) and EnergyPlus (via `pyenergyplus_lbnl`), are installed automatically.

## Quick Start

**Run a Radiance three-phase annual simulation:**

```python
import frads as fr

cfg = fr.WorkflowConfig.from_dict({
    "settings": {
        "method": "3phase",
        "wea_file": "weather.wea",
    },
    "model": {
        "scene": {"files": ["walls.rad", "floor.rad", "ceiling.rad"]},
        "windows": {"window1": {"file": "window.rad", "matrix_name": "bsdf1"}},
        "materials": {
            "files": ["materials.mat"],
            "matrices": {"bsdf1": {"matrix_file": "window.xml"}},
        },
        "sensors": {"workplane": {"file": "grid.txt"}},
    },
})

workflow = fr.ThreePhaseMethod(cfg)
workflow.generate_matrices()
illuminance = workflow.calculate_sensor(
    sensor="workplane",
    bsdf={"window1": "bsdf1"},
    time=..., dni=800, dhi=100,
)
```

**Run an EnergyPlus simulation with Radiance daylighting:**

```python
import frads as fr

epmodel = fr.load_energyplus_model("office.idf")
epmodel.add_glazing_system(
    fr.create_glazing_system("clear", [fr.LayerInput("clear.json")])
)

with fr.EnergyPlusSetup(epmodel, "weather.epw", enable_radiance=True) as eps:
    def controller(state):
        if not eps.api.exchange.api_data_fully_ready(state):
            return
        wpi = eps.calculate_wpi(zone="Zone1", cfs_name={"Window1": "clear"})
        eps.actuate_lighting_power("Zone1_Lights", (1 - min(wpi.mean() / 500, 1)) * 1000)

    eps.set_callback("callback_begin_system_timestep_before_predictor", controller)
    eps.run(annual=True)
```

## Documentation

Full documentation, how-to guides, and API reference are at **[lbnl-eta.github.io/frads](https://lbnl-eta.github.io/frads/)**.

## Citation

Wang, T., Ward, G., and Lee, E.S. (2021). A Python Library for Radiance Matrix-based Simulation Control and EnergyPlus Integration. *Proceedings of Building Simulation 2021*, IBPSA, Bruges. [PDF](https://www.researchgate.net/publication/358969936_A_Python_Library_for_Radiance_Matrix-based_Simulation_Control_and_EnergyPlus_Integration)

## License

Framework for Radiance Simulation Control (frads) Copyright (c) 2019, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Intellectual Property Office at IPO@lbl.gov.

NOTICE. This Software was developed under funding from the U.S. Department of Energy and the U.S. Government consequently retains certain rights. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, distribute copies to the public, prepare derivative works, and perform publicly and display publicly, and to permit others to do so.
