Add spectrally uniform, isotropic, spatially inhomogeneous volume emitter
Since we have the Discrete3DMesh, it would also be nice to have a cythonised InhomogeneousVolumeEmitter that gets emissivity as a Function3D instance. I think that this generalised version of the cherab.tools.emitters.RadiationFunction, will do the trick:
cdef class UniformInhomogeneousVolumeEmitter(InhomogeneousVolumeEmitter):
"""
Spectrally uniform, isotropic, spatially inhomogeneous volume emitter.
Uniform spectral emission will be given by the emission_spectrum multiplied by the
spatially inhomogeneous emission scale in radiance.
Note that the emission scale function will be evaluated in the local space of the
primitive to which this material is attached. For emission scale
functions defined in a different coordinate system, consider
wrapping this in a VolumeTransform material to ensure the function
evaluation takes place in the correct coordinate system.
:param SpectralFunction emission_spectrum: The volume's spectral emission function.
:param Function3D scale: Spatially inhomogeneous scale of the emission function
(default = 1 W/m^3/str/nm).
"""
def __init__(self, SpectralFunction emission_spectrum, object scale=1.0):
super().__init__()
self.emission_spectrum = emission_spectrum
self.scale = autowrap_function3d(scale)
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.initializedcheck(False)
cpdef Spectrum emission_function(self, Point3D point, Vector3D direction, Spectrum spectrum,
World world, Ray ray, Primitive primitive,
AffineMatrix3D world_to_primitive, AffineMatrix3D primitive_to_world):
cdef:
double[::1] emission
double scale
int index
emission = self.emission_spectrum.sample_mv(spectrum.min_wavelength, spectrum.max_wavelength, spectrum.bins)
scale = self.scale.evaluate(point.x, point.y, point.z)
for index in range(spectrum.bins):
spectrum.samples_mv[index] += emission[index] * scale
return spectrum
Please tell me if you have an idea for a shorter name.
@munechika-koyo, does this emitter suit your needs?
@vsnever Yes! This emitter is useful for the tetrahedra_mesh_emission demo program at least.
This was on the list of changes I intended to make for version 1.0. I want to increase the use of the function framework throughout raysect. The spectral functions and spectral sampling approaches need porting over (carefully) and the relevant materials rewritten. It would be best to wait for these changes to occur.
This was on the list of changes I intended to make for version 1.0. I want to increase the use of the function framework throughout raysect. The spectral functions and spectral sampling approaches need porting over (carefully) and the relevant materials rewritten. It would be best to wait for these changes to occur.
Ok, those who need this emitter can take it from here until then.