danieljfarrell / pvtrace

Optical ray tracing for luminescent materials and spectral converter photovoltaic devices
Other
97 stars 94 forks source link

Coating object only works with box geometries #10

Closed danieljfarrell closed 5 years ago

danieljfarrell commented 5 years ago

https://github.com/danieljfarrell/pvtrace/blob/080cdad9556ef7c84f6363d51d8502d205d1937b/pvtrace/Devices.py#L217

The coating object, which allows custom reflectivity calcualtions, has only ever been used with box geometies. Using it with cylinder geometies fails. I think this is because the initialiser of the coating object needs a few additional lines to handle cylinders.

Try changing this line, https://github.com/danieljfarrell/pvtrace/blob/080cdad9556ef7c84f6363d51d8502d205d1937b/pvtrace/Devices.py#L237

to,

        if isinstance(self.shape, Cylinder):
            self.radius = self.shape.radius
            self.length = self.shape.length
        elif not isinstance(self.shape, Polygon):
            self.origin = self.shape.origin
            self.size = np.abs(self.shape.extent - self.shape.origin)

However, I am not sure that will work. It could be the case that an assumption used by the ray tracer is that coatings are always box-like.

danieljfarrell commented 5 years ago

Made an attempt to fix this issue with this commit 597f095ec6a4d74c1ae782e7705515e86eb7acb9 however running scripts/debug_coating.py, and after generating a few rays, the tracing stops with a error in the fresnel refraction calculation. I imaging this is due to the coating angular reflectivity function has resulted in a ray direction which would never occur if the surface has pure Fresnel reflection. Unfortunately, this is not easy to solve. Mainly because the pvtrace 1.0 architecture is not really designed to deal with coating. They were added quickly and work only with box geometries (well that's how I used them anyway).

The solution here is to wait for pvtrace 2.0 which will have much better support for coatings.