Textures

This module is used to generate textures for interfaces (currently only for ray-tracing textures, but this could be expanded to surfaces for RCWA calculations). It contains both standard textures and functions to define your own ray-tracing textures from input coordinates.

Whether you are defining your own surface textures or using standard textures, you can pass additional arguments to these surfaces to specify surface layers, which will be treated optically using TMM. The relevant keyword arguments are:

  • interface_layers: a list of Solcore Layer objects

  • coherency_list: This is a list of the same length as interface_layers specifying which layers are coherent (“c”) and which are incoherent (“i”). If not provided, all layers are assumed to be coherent.

  • name: optional; name of the interface under which the TMM lookuptable will be saved.

See here for an example of how to use this in practice.

rayflare.textures.define_textures.heights_texture(z_points, x_width, y_width, **kwargs)

Defines RTSurface textures for ray-tracing based on a 2D array of z coordinates and the width along the x and y directions.

Parameters:
  • z_points – array of z (height) coordinates of points on the surface texture (2D numpy array)

  • x_width – width along the x direction

  • y_width – width along the y direction

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.define_textures.xyz_texture(x, y, z, **kwargs)

Defines RTSurface textures for ray-tracing based on lists of x, y and z coordinates provided by the user.

Parameters:
  • x – list of x (in-plane) coordinates of points on the surface texture (1D numpy array)

  • y – list of y (in-plane) coordinates of points on the surface texture (1D numpy array)

  • z – list of z (height) coordinates of points on the surface texture (1D numpy array)

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.standard_rt_textures.V_grooves(elevation_angle=55, width=1, direction='y', **kwargs)

Defines RTSurface textures for ray-tracing for a surface of V-grooves.

Parameters:
  • elevation_angle – angle between the horizontal and a face of the V-grooves, in degrres

  • width – width of the V-grooves (units are arbitrary but should be kept consistent between surfaces if you are not randomizing the ray positions).

  • direction – Whether the V-grooves lie along the ‘x’ or ‘y’ direction (string)

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.standard_rt_textures.hemisphere_surface(size=1, n_per_side=20, radius=0.5, offset=0, noise_angle=0, stretch=1, upright=True, **kwargs)

Creates a planar surface with a hemispherical cap embedded in it. The planar part of the surface can be rough. The hemisphere is centered at the center of the unit cell.

Parameters:
  • size – size of the unit cell; the units are arbitrary, but should be kept consistent across

  • n_per_side – the number of grid points per side (total number of points will be n_per_side**2)

  • radius – radius of the hemispherical cap

  • offset – the hemisphere is shifted DOWN by this value (any points which end up below the z = 0 surface will be removed from the surface)

  • noise_angle – the maximum opening angle/surface normal angle that will be used to generate the random noise. This is used to keep the height of the roughness for some noise_angle consistent with diferent n_points

  • stretch – factor by which the height of the hemispherical cap is stretched (for ellipsoid rather than spheres)

Returns:

rayflare.textures.standard_rt_textures.hyperhemisphere(N_points=32768, radius=1, h=0, **kwargs)

Defines RTSurface textures for ray-tracing of a (hyper)hemisphere. Useful for hemispherical or hyperhemispherical lenses. Note that this is a surface of the hyperhemisphere only, and not a surrounding surface which reaches the unit cell edges. The sphere will be open at the bottom. The points for the sphere are generated using the ‘Golden Spiral’. Code by Chris Colbert from the numpy-discussion list.

Parameters:
  • N_points – Number of points on the sphere. The final surface may have fewer points depending on h.

  • radius – radius of the sphere (units are arbitrary but should be kept consistent between surfaces)

  • h – by how much the origin of the sphere is raised or lowered. With h=0, a hemisphere is returned with the origin at the center of the hemisphere. With h=radius, the whole sphere is returned; with negative h, the hemisphere is truncated.

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.standard_rt_textures.planar_surface(size=1, **kwargs)

Defines RTSurface textures for ray-tracing for a planar surface for ray-tracing.

Parameters:

size – size of the unit cell (this should not affect the results, as the surface is planar).

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.standard_rt_textures.regular_pyramids(elevation_angle=55, upright=True, size=1, **kwargs)

Defines RTSurface textures for ray-tracing of regular upright or inverted regular square-base pyramids.

Parameters:
  • elevation_angle – angle between the horizontal and a face of the pyramid, in degrees

  • upright – if True, upright pyramids. If False, inverted pyramids. Whether the pyramids are upright or inverted is always from the perspective of the front incidence surface, so for pyramids facing out on the rear surface of a cell, you would set upright=False.

  • size – size of the pyramids; the units are arbitrary, but should be kept consistent across different interfaces if you are not randomizing the ray positions.

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.standard_rt_textures.rough_planar_surface(size=1, noise_angle=0.1, n_points=100, regular_grid=False, **kwargs)

Defines RTSurface textures for ray-tracing of regular upright or inverted regular square-base pyramids, with random noise added to the height of each point to simulate surface roughness.

Parameters:
  • size – size of the unit cell; the units are arbitrary, but should be kept consistent across different interfaces.

  • noise_angle – the maximum opening angle/surface normal angle that will be used to generate the random noise. This is used to keep the height of the roughness for some noise_angle consistent with diferent n_points

  • n_points – number of points to use to define the surface (in total, not per side). Noise will be added to the height of each point so a large number means a texture with smaller features

  • regular_grid – if True, the points will be placed on a regular grid. If False, the points will be placed randomly in the unit cell. n_points will be rounded up to the nearest square number if regular_grid=True.

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]

rayflare.textures.standard_rt_textures.rough_pyramids(elevation_angle=55, upright=True, size=1, noise_angle=0.1, n_points=100, regular_grid=False, **kwargs)

Defines RTSurface textures for ray-tracing of regular upright or inverted regular square-base pyramids, with random noise added to the height of each point to simulate surface roughness.

Parameters:
  • elevation_angle – angle between the horizontal and a face of the pyramid, in degrees

  • upright – if True, upright pyramids. If False, inverted pyramids. Whether the pyramids are upright or inverted is always from the perspective of the front incidence surface, so for pyramids facing out on the rear surface of a cell, you would set upright=False.

  • size – size of the pyramids; the units are arbitrary, but should be kept consistent across different interfaces if you are not randomizing the ray positions.

  • noise_angle – the maximum opening angle/surface normal angle that will be used to generate the random noise. This is used to keep the height of the roughness for some noise_angle consistent with diferent n_points

  • n_points – number of points to use to define the surface (in total, not per side). Noise will be added to the height of each point so a large number means a texture with smaller features

  • regular_grid – if True, the points will be placed on a regular grid. If False, the points will be placed randomly in the unit cell. n_points will be rounded up to the nearest square number if regular_grid=True.

Returns:

a list of two RTSurface objects: [front_incidence, rear_incidence]