User Tools

Site Tools


tutorials:use_fluxmodel

This is an old revision of the document!


In this tutorial we will see how to get started with a FluxModel in GroIMP.

Light Model

First, we setup of the Flux Light Model:

import de.grogra.gpuflux.tracer.FluxLightModelTracer.MeasureMode;
import de.grogra.gpuflux.scene.experiment.Measurement;
 
const int RAYS = 10000000;
const int DEPTH = 10;
const FluxLightModel LM = new FluxLightModel(RAYS,
DEPTH);
 
protected void init () {
LM.setMeasureMode(MeasureMode.FULL_SPECTRUM);
LM.setSpectralBuckets(81);
LM.setSpectralDomain(380, 780);
}

This is:

  1. importing of the needed classes
  2. initializing the model with 10 million rays and a recursion depth of 10
  3. setting the parameters with 400nm divided into 80 buckets of 5nm.

Then, run the light model and determine the amount of sensed radiation or of absorbed power for an object-type.

public void run () [
{
LM.compute();
}
 
 
x:SensorNode ::> {
Measurement spectrum = LM.getSensedIrradianceMeasurement(x);
float absorbedPower = spectrum.integrate();
//...
} 
 
x:Box ::> {
Measurement spectrum = LM.getAbsorbedPowerMeasurement(x);
float absorbedPower = spectrum.integrate();
//...
}
]

This is:

  1. computing the model
  2. computing the integration of the whole absorbed spectrum for both
  3. sensor nodes
  4. box objects

Demonstration of the method for the determination of the amount of absorbed power per bucket or integration over a certain spectral range.

Measurement spectrum = LM.getAbsorbedPowerMeasurement(x); 
 
//absorbed power for the first bucket: 380-385 nm
float ap380_385 = spectrum.data[0]; 
 
//accumulate absorbed power for the first four 50 nm buckets
float b0 = 0, b1 = 0, b2 = 0, b3 = 0;
for (int i:(0:10)) {
b0 += spectrum.data[i];
b1 += spectrum.data[i + 10];
b2 += spectrum.data[i + 20];
b3 += spectrum.data[i + 30];
} 
 
//integrate the whole spectrum
float ap = spectrum.integrate();

This is:

  1. Getting the absorbed spectrum
  2. Storing the first bucket in a variable
  3. building four integrals, each of 50 nm (10 buckets of 5 nm) and sum up the first 40 buckets.
  4. calculating the integral over the whole spectrum.

Light Sources

Now let's set up a parameterisable light node – with explicit definition of physical light and spectral power distribution by simple arrays:

import de.grogra.imp3d.spectral.IrregularSpectralCurve; 
 
const double[][] DISTRIBUTION = {
{131.25, 131.67, 132.37, ...},
{131.36, 131.81, ...},
...
};
 
static const float[] WAVELENGTHS = {380,385, ...};
static const float[] AMPLITUDES = {0.000967,0.000980, ...};
 
module MyLamp extends LightNode() {
{
setLight(new SpectralLight(
new IrregularSpectralCurve(WAVELENGTHS, AMPLITUDES)).(
setPower(10), //[W]
setLight(new PhysicalLight(DISTRIBUTION))));
}
}
tutorials/use_fluxmodel.1714393634.txt.gz · Last modified: 2024/04/29 14:27 by gaetan