Skip to main content

Optical ray tracing for luminescent materials and spectral converter photovoltaic devices.

Project description

Optical ray tracing for luminescent materials and spectral converter photovoltaic devices

Install

pip install pvtrace

Introduction

pvtrace is a statistical photon path tracer written in Python. It follows photons through a 3D scene and records their interactions with objects to build up statistical information about energy flow. This approach is particularly useful in photovoltaics and non-imaging optics where the goal is to design systems which efficiently transport light to target locations.

Documentation

Interactive Jupyter notebooks are in examples directory, download and take a look, although they can be viewed online.

API documentation and some background at https://pvtrace.readthedocs.io

Capabilities

pvtrace was originally written to characterise the performance of Luminescent Solar Concentrators (LSC) and takes a Monte-Carlo approach to ray-tracing. Each ray is independent and can interact with objects in the scene via reflection and refraction. Objects can have different optical properties: refractive index, absorption coefficient, emission spectrum and quantum yield.

One of the key features of pvtrace is the ability to simulate re-absorption of photons in luminescent materials. This requires following thousands of rays to build intensity profiles and spectra of incoming and outgoing photons because these process cannot be approximated in a continuous way.

pvtrace may also be useful to researches or designers interested in ray-optics simulations but will be slower at running these simulations compared to other software packages because it follows each ray individually.

A minimal working example that traces a glass sphere

import time
import sys
import functools
import numpy as np
from pvtrace import *

world = Node(
    name="world (air)",
    geometry=Sphere(
        radius=10.0,
        material=Material(refractive_index=1.0),
    )
)

sphere = Node(
    name="sphere (glass)",
    geometry=Sphere(
        radius=1.0,
        material=Material(refractive_index=1.5),
    ),
    parent=world
)
sphere.location = (0, 0, 2)

light = Node(
    name="Light (555nm)",
    light=Light(direction=functools.partial(cone, np.pi/8)),
    parent=world
)

renderer = MeshcatRenderer(wireframe=True, open_browser=True)
scene = Scene(world)
renderer.render(scene)
for ray in scene.emit(100):
    steps = photon_tracer.follow(scene, ray)
    path, events = zip(*steps)
    renderer.add_ray_path(path)
    time.sleep(0.1)

# Wait for Ctrl-C to terminate the script; keep the window open
print("Ctrl-C to close")
while True:
    try:
        time.sleep(.3)
    except KeyboardInterrupt:
        sys.exit()

Architecture

pvtrace is designed in layers each with as limited scope as possible.

Scene
Graph data structure of node and the thing that is ray-traced.
Node
Provides a coordinate system, can be nested inside one another, perform arbitrary rotation and translation transformations.
Geometry
Attached to nodes to define different shapes (Sphere, Box, Cylinder, Mesh) and handles all ray intersections.
Material
Attached to geometry objects to assign physical properties to shapes such as refractive index.
Surface
Handles details of interaction between material surfaces and a customisation point for simulation of wavelength selective coatings.
Components
Specifies optical properties of the geometries volume, absorption coefficient, scattering coefficient, quantum yield, emission spectrum.

Dependancies

  • python >= 3.7.2
  • trimesh (for mesh shapes)
  • meshcat (for visualisation)
  • numpy
  • anytree

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pvtrace-2.1.0.tar.gz (54.3 kB view details)

Uploaded Source

File details

Details for the file pvtrace-2.1.0.tar.gz.

File metadata

  • Download URL: pvtrace-2.1.0.tar.gz
  • Upload date:
  • Size: 54.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pvtrace-2.1.0.tar.gz
Algorithm Hash digest
SHA256 7b5d4843f70bec07b2515610e9d7e38892456fbf2380f55744694b1ae4db61bc
MD5 e5eab040fbd970426933e4c23bf23b1e
BLAKE2b-256 3e6dcbb9221630dcab3ece5b88bf2059e01b6b03f29dfb0feb5a683cb6bb0446

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page