NPSpec
0.2.0
Solve for the spectral properties of nanoparticles easily
|
The C-interface to the NPSpec library. More...
#include "npspec/constants.h"
Go to the source code of this file.
Functions | |
int | material_index (const char *material) |
Function to return the index of a material. Used internally to locate the parameters for each material. More... | |
enum ErrorCode | npspec (const int nlayers, const double rad[2], const double rel_rad[][2], const int indx[], const double mrefrac, const bool size_correct, const int increment, const double path_length, const double concentration, const enum SpectraType spectra_type, double extinct[], double scat[], double absorb[]) |
This function is used to calculate the spectra of a nanoparticle. More... | |
void | RGB (const double spec_in[], const int inc, const bool trans, double *r, double *g, double *b) |
Given a spectra as calculated by npspec, return the color in RGB color space. More... | |
void | RGB_to_HSV (const double r, const double g, const double b, double *h, double *s, double *v) |
Convert a color in RGB color space to HSV color space. More... | |
The C-interface to the NPSpec library.
int material_index | ( | const char * | material | ) |
Function to return the index of a material. Used internally to locate the parameters for each material.
material | This is the material/element name to find the integer index of. |
Currently, the following materials are implemented: Ag, AlAs, AlSb, Au, Be, CdS, CdSe, Co, Cr, Cu, Cu2O, CuO, Diamond, Diamond_film, GaAs, GaP, Ge, Glass, Graphite, InAs, InP, InSb, Ir, K, Li, Mo, Na, Nb, Ni, Os, PbS, PbSe, PbTe, Pd, Pt, Quartz, Rh, Si, SiC, SiO, Ta, Te, TiO2, V, W, ZnS, ZnSe, ZnTe
enum ErrorCode npspec | ( | const int | nlayers, |
const double | rad[2], | ||
const double | rel_rad[][2], | ||
const int | indx[], | ||
const double | mrefrac, | ||
const bool | size_correct, | ||
const int | increment, | ||
const double | path_length, | ||
const double | concentration, | ||
const enum SpectraType | spectra_type, | ||
double | extinct[], | ||
double | scat[], | ||
double | absorb[] | ||
) |
This function is used to calculate the spectra of a nanoparticle.
[in] | nlayers | The number of layers in the nanoparticle. This cannot be greater than 10. |
[in] | rad | An array of length 2 representing the nanoparticle radius on the Z axis and the radius on the XY axis. If the XY axis component is <0, it is assumed that the particle is a sphere and mie theory will be used. Otherwise the quasistatic approzimation is used. |
[in] | rel_rad | An array of length nlayers x 2 which indicates the relative radius of each layer in the. Each component (Z axis and XY axis) must sum to 1.0. |
[in] | indx | The integer index of the material/element to calculate. It is an array of length nlayers. |
[in] | mrefrac | The refractive index of the surrounding medium. |
[in] | size_correct | Should we size correct the dielectric function? |
[in] | increment | This is the increment to use when looping over the wavelengths. There are 800 wavelengths in increments of 1 nm. This value must be a factor 800. This is useful if you have to repeatedly calculate the spectrum such as in a real-time GUI. |
[in] | path_length | When calculating absorption, this is the Beer's law path length in cm to use. |
[in] | concentration | When calculating absorption, this is the Beer's law path concentration in molarity to use. |
[in] | spectra_type | The spectra type to calculate. It is an enum of SpectraType. |
[out] | extinct | This is the extinction spectra calculated by the given parameters. |
[out] | scat | This is the scattering spectra calculated by the given parameters. |
[out] | absorb | This is the absorbance spectra calculated by the given parameters. |
void RGB | ( | const double | spec_in[], |
const int | inc, | ||
const bool | trans, | ||
double * | r, | ||
double * | g, | ||
double * | b | ||
) |
Given a spectra as calculated by npspec, return the color in RGB color space.
[in] | spec_in | The spectrum that is calculated by npspec. |
[in] | inc | The increment used when calculating spec_in. |
[in] | trans | Calculated assuming transmission instead of absorption (currently not used). |
[out] | r | The RED component of RGB color space, between 0 and 1 (inclusive). |
[out] | g | The GREEN component of RGB color space, between 0 and 1 (inclusive). |
[out] | b | The BLUE component of RGB color space, between 0 and 1 (inclusive). |
TODO: Calculate the color for absorbtion and transmission differently.
void RGB_to_HSV | ( | const double | r, |
const double | g, | ||
const double | b, | ||
double * | h, | ||
double * | s, | ||
double * | v | ||
) |
Convert a color in RGB color space to HSV color space.
[in] | r | The RED component of RGB color space, between 0 and 1 (inclusive). |
[in] | g | The GREEN component of RGB color space, between 0 and 1 (inclusive). |
[in] | b | The BLUE component of RGB color space, between 0 and 1 (inclusive). |
[out] | h | The HUE component of HSV color space, between 0 and 360 (inclusive). |
[out] | s | The SATURATION component of HSV color space, between 0 and 1 (inclusive). |
[out] | v | The VALUE component of HSV color space, between 0 and 1 (inclusive). |