# Grasshopper API manual

## Install Grasshopper plugin

AiPlantCare Grasshopper plugin is an open-source and free-of-charge API to our cloud computing services. This feature helps designers and architects who have already a 3D model in Grasshopper or Rhino and wants to evaluate lighting situation for occupants and plants.&#x20;

AiPlantCare plugin makes it possible to upload your project specifications and 3D geometry to our server smoothly. Cloud-based computing services makes it easy to benefits from powerful simulation engines such as Radiance.&#x20;

There is no need for installation of these tools, preparing geometry and material, and dealing with steep learning curve to get it ready for annual daylighting assessment or calculating photosynthetically active radiation (PAR) and daily light integral (DLI) for plants. By downloading the result files (\*.csv) post processing and visualizing the performance indicators will be easy in Grasshopper.

**Installation:** You can install the AiPlantCare package manually by downloading it from [Food4Rhino](https://www.food4rhino.com/en/app/aiplantcare).&#x20;

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-MjzUJNlYVLnDjjZBrku%2F-MjzVDDpGUlwrbt89mZe%2FNew%20Project%20\(12\).png?alt=media\&token=b73458ff-3c6d-4ee5-9b67-198af551fe2c)

Place the downloaded files (\*.ghuser) in the User Objects folder C:\Users\\...\AppData\Roaming\Grasshopper\UserObjects. That folder can be found in Edit > Special Folders > User Objects Folder.

## Video Tutorial  [**AiPlantCare - Rhino Grasshopper API**](https://www.youtube.com/watch?v=LWZBCHW8iFc)

This video includes:

1. How to download and install the grasshopper components from Fod4Rhino
2. How to register on the website and get your API-Token. (Early access is free of charge!)
3. How to use our Ready2Use template and start your first simulation
4. How to load the results and start post processing and visualization

![AiPlantCare - Rhino Grasshopper API](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzezH8xUwJGLVKY-Le%2Fimage.png?alt=media\&token=b4a61744-27b2-4aa2-bbf4-12cb01f3eb3a)

## Make your account at aiplantcare.com

Go to the [sign up page](https://www.aiplantcare.com/login) and register to get started. Early access is free of charge.

You may decide first to use a free service or benefits from unlimited professional features by reading the advantages in [here](https://www.aiplantcare.com/pricing).

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Faiplantcare-documentation%2F-MhIJRLJGNg9fJVADMxx%2F-MhIZHkyTtz34fNLjTxK%2F1.png?generation=1629194629556623\&alt=media)

By starting an account, you can use web-based tools and cloud services, as well as the Rhino API services. Logging in to your account leads you to your Dashboard. Dashboard includes your projects, plant species data sets, and simulation set-ups. You can always access to the archive of your models and results. Warning! for the early access all these features are enable until the expiration date.

Dashboard includes your Projects | Plants | General Settings | Payments. After activating your Early Access in "Payments", you should go to “General Settings”, to get your API token for using in Grasshopper Plugin.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Faiplantcare-documentation%2F-MhIJRLJGNg9fJVADMxx%2F-MhIZHkzBzJUFuCiaeH_%2F2.png?generation=1629194629332419\&alt=media)

## Create a new project and start cloud-based simulation

The AiPlantCare Call is the main Grasshopper component to communicate with our cloud base services. Having an AiPlantCare account, you can get your unique API token from your Dashboard. Your “Username” should be as your registered account in our website.

The “Project Name” can be set as you wish, and you can access to the results under the same project name. Keep in mind that if you have already simulated a project with this name, running with the same name retrieve the already existing data on the cloud.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzcRneprEmNIca_d6S%2FAiPlantsCare_Rhino_API_2.png?alt=media\&token=5fc8208c-9764-4aa5-a2ec-5383b5bfba9d)

You need to specify the location of your project. You can just specify your latitude and longitude, and then the system will find the closest weather station to your project automatically. Alternatively, you can give us a link to the TMY weather data you want to use in your study. This link should be **a downloadable link to a file with epw format**. You can find many of these file on the energyplus.net/weather-download webpage free of charge.

The geometries and material setting should be defined and converted to obj format under the same project name before any call to our cloud server. This obj file must be generated by using following components based on our protocols for layer names and materials.

* **AiPlantcare\_Rh2Obj** > convert Rhino geometry into obj file format
* **AiPlantcare\_Material** > assign material to each layer name. This can be solar transmittance for windows or reflectance of opaque surfaces. We also suggest to define trees under win group and adjust its properties by using transmittance (0: a tree with dense foliage; >0.8 : an almost naked tree). And workplanes should be named as wp0, wp1, ...

When everything seems ready press the button once to Call to the AiPlantCare server. This process may take few seconds regarding to the size of your model, the number of sensor points. You can later check on your online dashboard if the project is online and whether the simulation is started or not?&#x20;

The simulation may take few minutes based on the size of your model, the number of sensor points, and rayTracingQuality choice. The rayTracingQuality specifies the Radiance simulation parameters. Under the hood, we run a DC method simulation and you can adjust it to get a higher quality in your results (by default rayTracingQuality == 1: ' -ab 3 -ad 1024 -ar 1024 -as 128 -aa 0.1').

## Prepare the model for simulation

### Building 3D geometry

In Rhino environment, the 3D geometry for analyzing may include unlimited number of surfaces and meshes (delete all points, lines, curves). This model however should be simple as recommended for a daylight simulation. You should categorize the surfaces into main categories of opaque or transparent surfaces.&#x20;

The opaque surfaces and obstacles with the same reflectivity value (or color) should be set in one layer (with specific layer name that you can recall later). Reflectivity can vary in the range of 0 (dark) to 1 (bright).&#x20;

The window surfaces with the same transmissivity should be set in one layer (with specific layer name that you can recall later). Transmissivity can vary in the range of 1 (fully clear) to 0 (fully tinted/dark). For instance, if you have walls and ceiling with the same color or reflectivity, they should be defined as one opaque layer (e.g. opaque0 with Ref. 0.6). If you have two different window one darker than the other more transparent, one can be set in layer Win0 (Trn. 0.60) and the other in Win1 (Trn. 0.85). The layers must be named carefully, since the material properties will be assigned later corresponding these names.

Keep in mind that the window opening needs to be cut through the wall or the ceiling. Normal vector of the faces are not important but for the work planes analysis mesh.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Faiplantcare-documentation%2F-MhIJRLJGNg9fJVADMxx%2F-MhIZHl-qJdzgmf71_u4%2F3.png?generation=1629194629408835\&alt=media)

If the 3D model is generated in Grasshopper environment, it must be baked first with the required layers names. You can use the AiPlantCare baking component, which gets a geometry and a layer name and bakes your generative model, as it is required.

### Work plane

The work plane (aka. analysis mesh) is an imaginary plane that you want to evaluate the level of daylighting on that surface. So, it can be a horizontal plane above the floor (normally 80 cm) or a vertical surface close to the wall you want to place a green-wall. The work plane can be either inside the room or outside on the façade surface. To create the work plane a mesh with desire discretization should be created in Rhino or Grasshopper.

The number of meshes as well as the normal vectors orientation are very crucial because the system will set the sensor points resolution and their orientation (e.g. facing upward or downward) based on this analysis mesh. These virtual sensor points represents a lux meter or par meter sensor on that exact place and after the calculation you can get hourly values on each sensor point. The higher the number of sensors the higher resolution in your results and the more required computation power and simulation time.

It is highly recommended to check normal face of these meshes in Rhino under “Analyze > Show Object Direction”, before starting any simulations. Multiple number of work planes can be defined. Finally, the analysis meshes should be baked and set with the correct layer names as “wpx”.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Faiplantcare-documentation%2F-MhIJRLJGNg9fJVADMxx%2F-MhIZHl1US5gR0dMNs5h%2F5.png?generation=1629194629358455\&alt=media) ![MQ-500: Full-Spectrum Quantum Meter](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Faiplantcare-documentation%2F-MhIJRLJGNg9fJVADMxx%2F-MhIZHl2aAzFIbdr_7xI%2F6.jpeg?generation=1629194629325109\&alt=media)

Keep in mind that at least one work plane needs to be exist in your model. Projects without work plane (sensor points) cannot be simulated. Any other unnecessary layers, objects, surfaces, lines, curves, and points must be removed from your Rhino model. The orientation and elevation of your model must be set carefully (+y in Rhino is assumed toward North) before using the Rh2obj component.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-Mjzc90al9GYkB9St54g%2FAiPlantsCare_Rhino_API_0.png?alt=media\&token=98c05bcf-a0ce-4340-a40d-268006efcd1d)

The projectName.obj is a copy of the geometry used for the simulation. It will be generated in your local folder: C:\Users\\...\Local\Temp\aiplantcare\ if only the **writeObj** input in AiPlantcare\_Rh2Obj component was set to “True”.

### Material setting

AiPlantCare benefits from Radiance simulation engine and every material in your model is translated into simplified material types readable for Radiance. For defining the surface properties, you can use “Material Setting” component in Grasshopper.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzcFxtZTfxBrzupuKH%2FAiPlantsCare_Rhino_API_1.png?alt=media\&token=c3b71ee8-c6cc-471e-8b20-1ee529a1f4c1)

Warning! Each visible layer name in Rhino will be converted to .obj and will be used in our simulation. Therefore, each layer must have a corresponding material definition here in py code under one of these groups (dictionaries):

```
# -- wins ------------------------------------------------------
win = {
        "Window": trans1,
        "Skylight": trans2,
        "Tree": trans3
        }

# -- opaques ------------------------------------------------------
opaq = {
        "Context": reflect1,
        "Shading": reflect2,
        "Room": reflect3
        }

# -- Workplanes ------------------------------------------------------
wp = {
        "wp0": True, 
        "wp1": True, 
        "wp2": True,
        "wp3": True,
        "wp4": True,
        "wp5": True
        }
```

You just need to open the py code and make sure your layer has a line and is set to an input to the component such as trans1 or reflect1.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mk1cyQqPP33lvzag5x7%2F-Mk1khsnrc6TEa2bGDMJ%2Fimage.png?alt=media\&token=d164adf0-39e5-4b36-bcf6-df98f315dd46)

The opaque surfaces are defined as “plastic” material where the reflectivity value is used for all three RGB channels equally (no color, only gray) with no roughness and specularity. Other obstacles, objects, furniture were treated as opaque surface as well.

The window surfaces are defined as “glass” material where the transmissivity value is converted into transmittance and used for all three RGB channels equally (no color, only gray). The tree canopies can be defined as glass material. Therefore, if you want to represent a tree with a dense foliage, you can use low transmissivity value and if it allows more light to be passed through, you can define it with higher transmissivity value.

Workplanes are imaginary surfaces and are not considered as real obstacle in you model. Please keep in mind that the work plane should not cover any other surfaces. In this case, that part of the surface will be disappeared as well.

## Loading the results in Grasshopper

After a successful simulation on the cloud, the resultant files as below will be downloaded on your local folder: C:\Users\\...\Local\Temp\aiplantcare\\

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-Mjzcw-QfNqvB_wxsHGn%2FAiPlantsCare_Rhino_API_3.png?alt=media\&token=5fc6e745-3710-4bad-9e15-ea4f08d3febd)

* ProjectName.pts includes the position of sensor points (x,y,z) and the normal vectors (x,y,z)
* ProjectName.ill includes the hourly photometric values (illuminance - lx) for each sensor point. It normally goes from 0 to 8760.
* ProjectName.par includes the hourly photosynthetically active radiation (PAR, weighted in 400-700 nm range) values (μmol/m².s) for each sensor point. It normally goes from 1 to 8760 hours over a year.
* ProjectName.dli includes the daily light integral (DLI) values (mol/m².day) for each sensor point. DLI expresses the total amount of PAR, which is accumulative on a surface in 24 hours. DLI for each single day over a year can be shown (from 1 to 365 days).

For post-processing and visualizing you can open these csv files in excel or you can use the component below to load the results in Grasshopper.

## Annual Metric for Biophilic design&#x20;

We calculate hourly PAR values on the sensors-grid and Daily light integral (DLI) which have been used in horticulture for decades to express lighting for plants, We introduced annual metric to evaluate the buildings in an early stage of design:

1. **Annual DLI Autonomy** (DLIa10) is an annual metric which describes how many day in year (as percentage), a certain point in a room receives enough natural daylight (DLImin  based on the type of cultivar, e.g. 10 mol/m²∙d ).&#x20;
2. **Spatial DLI Autonomy** (sDLIa10) describes how much space receives enough DLI (in DLI-target range) over the course of a year
3. **Annual PAR exceeded** (APE350) was defined to be checked as a pass/fail metric. APE describes how many hours on a certain point a room receives too much sunlight (above PAR cut-off e.g. 350 μmol/m²∙s). The value for PAR cut-off is based on the light saturation point of plant species and may range from 90 μmol/m²∙s to 350 μmol/m²∙s respectively for tulip and rose.&#x20;
4. S**patial Annual PAR exceeded** (sAPE350) describes how much of space receives excess PAR (assuming the cut-off upper limit, e.g. 350 μmol/m²∙s).
5. **Annual Risk of Plants SunBurn** (RPS350\_5hr) describes how many days in year on a certain point in a room receives PAR above cut-off level (e.g. 350 μmol/m²∙s) and longer than the daily limit (e.g. 5 hours in a day). This metric shows the risk of plant sunburn when plants do not have enough time to overcome light stress.
6. **Total Annual electricity demand for artificial lighting (kWh/year) and lighting schedule**, an hourly time series profile with required fraction of supplemental light (0-1). These calculations are based on the selected Grow Light’s parameters such as: location in the room and Photosynthetic Photon Flux Density (PPFD). PPFD is the amount of light that actually reaches your plants within the PAR spectrum in μmol/s.m².
7. **Annual shading schedule**, an hourly time series profile with required fraction of sun protection on your windows (0-1) for a complete year. This profile is calculated based on receiving excess PAR (assuming the cut-off upper limit, e.g. 350 μmol/m²∙s) in different places in the room.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzeQotkcfEiujgj8yv%2FAiPlantsCare_Rhino_API_model.png?alt=media\&token=71b8c340-0888-4525-8f09-94a70ad4156b)

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzeTdzz_ck6rlO9AWQ%2FAiPlantsCare_Rhino_API_DLIa_results.png?alt=media\&token=b09682b3-d077-4fb2-ae75-89b2bcb1e274)

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzelF8ndZj4SOeJm2N%2FAiPlantsCare_Rhino_API_results_DLIa_DLIe.png?alt=media\&token=9104bc1c-2415-4e8f-8b91-fe22dee45eb4)

## Analysis and visualization

### **Climate based daylight analysis for both humans and plants:**

1. Point in time daylighting for occupants: hourly illuminance values (lx) and its distribution on the work plane over the course of a year (8760 hrs).
2. Annual daylighting for occupants: Useful Daylight Index (UDI%) is a daylight availability metric that corresponds to the percentage of the occupied time when a target range of illuminances (e.g. 300-2500lx) at a point in a space is met by daylight. This metric describes the amount of time a space is either: Too Dim (UDIs: supplementary), Well lit (UDIa: acceptable), or Too bright (UDIe: excessive). The occupancy schedule (how often and from when to when the space will be used) is also an important input for this calculation.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzdDGK9qpcZ1Se2vqg%2FAiPlantsCare_Rhino_API_4-1.png?alt=media\&token=c2d71191-5479-4af1-9fa9-d2f9b3765e76)

1. Point in time DLI for plants: daily light integral (DLI) values (mol/m².d) and its distribution on the work plane over the course of a year (365 days). DLI) describes the number of photosynthetically active photons (PAR in 400-700 nm range) that are delivered to the work plane over a 24-hour period. This metric describes very well the available light for plants. Each plant species (cultivar) has a DLI target which growth of that plant can be guaranteed. By comparing DLI available to DLI target the supplementary light requirement can be estimated.
2. Annual DLI for plants: DLI% index is a sunlight availability metric for plants that corresponds to the percentage of days when DLI target at a point in a space is met by natural light only. This metric also describes the amount of time a space is either: Too Dim (DLIs: supplementary), Well lit (DLIa: acceptable), or Too bright (DLIe: excessive). For this study, desired plant species and the corresponding DLI target should be selected first.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzdPjkxNMx1EMwrtkH%2FAiPlantsCare_Rhino_API_4-2.png?alt=media\&token=2d3061fc-f818-4e4e-bdd3-a3aaf12a75ab)

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-Mjze0q3OPGy2108mxmH%2FAiPlantsCare_Rhino_API_4-3.png?alt=media\&token=a18c3142-5e26-4229-8554-bdd490b1e1be)

### **Electricity consumption for supplementary lighting (kWh)**

In a human centric design, we consider the location of the occupants in the space and estimate the total electricity energy needed for supplementary lighting (artificial lighting) in addition to the natural daylight. If the place is closer to the window or skylight, this energy consumption is less. The occupancy schedule is also an important input for this calculation.&#x20;

By selecting one the sensor points (among all points on the work plane), we assumed that the lighting control should be controlled based on the available natural light on that specific point.

In this component, a target range is defined. If the natural light on the sensor goes below the lower limit, the light turns on (100%) and if the available light goes beyond the upper limit the light turns off (0%). A linear dimming function is assumed for the values between the lower and upper limits.

The electrical power (watt) and the efficacy of the luminaries for humans (lm/W) and equivalent Photosynthetic Photon Flux Density (PPFD) factor of the lights needs to be specified by the users. PPFD factor shows the equivalent amount of photometric values (illuminance - lux) which can be used actively for photosynthesize in plants.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhIIhVPRhmwvwGn8s5d%2F-Mjzb-zn35Koj7m6Jg30%2F-MjzdpZ4KO_xw5NYQshW%2FAiPlantsCare_Rhino_API_5.png?alt=media\&token=e6592054-81f1-491d-9a7f-02a3d0d9da9e)

In a plant centric design, we consider the location of plant(s) in the space. It may be the whole area or a limited area that you consider for indoor growing. The estimation of the total electricity energy then will be done based on the selected sensor point. If the surface you are going to cover with a green wall for example does not receive the same amount of light, the position of your sensor matters more. Then if you locate the sensor in a place darker than the average, the energy consumption is overestimated and vice versa.

For plants, the occupancy schedule is not required since the plants supposed to be there all day long.

The lighting control is based on the available natural light on that specific point. For plants, DLI target range is used as lower and upper limits.

The electrical power (watt) and the equivalent Photosynthetic Photon Flux Density (PPFD) of the grow lights needs to be specified by the users. The PPFD values can be found easily on the grow lights providers’ website or products specifications.

## Plants species datasets

For assessing the daylight situation for your plant, it is required to define an optimal range of DLI for plants. This data is available for most commonly used houseplants: Houseplants, Cacti and succulents, Greenwalls, Edible, and Purifiers plants.

![](https://232073247-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Faiplantcare-documentation%2F-MhIJRLJGNg9fJVADMxx%2F-MhIZHlDFgFg7IzzNrsr%2F17.png?generation=1629194629452939\&alt=media)

Our database on the website includes larger number of plants species (+100,000) and a feature to recognize your plant from an image.
