NPSpec  0.2.0
Solve for the spectral properties of nanoparticles easily
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Functions
npspec.h File Reference

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...
 

Detailed Description

The C-interface to the NPSpec library.

Function Documentation

int material_index ( const char *  material)

Function to return the index of a material. Used internally to locate the parameters for each material.

Parameters
materialThis is the material/element name to find the integer index of.
Returns
The integer corresponding to the material. -1 is returned if the material is not found.

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.

Parameters
[in]nlayersThe number of layers in the nanoparticle. This cannot be greater than 10.
[in]radAn 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_radAn 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]indxThe integer index of the material/element to calculate. It is an array of length nlayers.
[in]mrefracThe refractive index of the surrounding medium.
[in]size_correctShould we size correct the dielectric function?
[in]incrementThis 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_lengthWhen calculating absorption, this is the Beer's law path length in cm to use.
[in]concentrationWhen calculating absorption, this is the Beer's law path concentration in molarity to use.
[in]spectra_typeThe spectra type to calculate. It is an enum of SpectraType.
[out]extinctThis is the extinction spectra calculated by the given parameters.
[out]scatThis is the scattering spectra calculated by the given parameters.
[out]absorbThis is the absorbance spectra calculated by the given parameters.
Returns
The error code indicating what went wrong if the calculation failed.
Warning
For an ellipse a max of two layers are allowed.
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.

Parameters
[in]spec_inThe spectrum that is calculated by npspec.
[in]incThe increment used when calculating spec_in.
[in]transCalculated assuming transmission instead of absorption (currently not used).
[out]rThe RED component of RGB color space, between 0 and 1 (inclusive).
[out]gThe GREEN component of RGB color space, between 0 and 1 (inclusive).
[out]bThe 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.

Parameters
[in]rThe RED component of RGB color space, between 0 and 1 (inclusive).
[in]gThe GREEN component of RGB color space, between 0 and 1 (inclusive).
[in]bThe BLUE component of RGB color space, between 0 and 1 (inclusive).
[out]hThe HUE component of HSV color space, between 0 and 360 (inclusive).
[out]sThe SATURATION component of HSV color space, between 0 and 1 (inclusive).
[out]vThe VALUE component of HSV color space, between 0 and 1 (inclusive).