NPSpec
0.2.0
Solve for the spectral properties of nanoparticles easily
|
Class to hold nanoparticle definition and calculate its spectrum. The interface for Python is the same as this C++ API. More...
#include <nanoparticle.hpp>
Public Member Functions | |
Nanoparticle () | |
Constructor. More... | |
int | calculateSpectrum () |
Calculate the spectra. More... | |
void | getSpectrum (double spec[NPSpec::NLAMBDA]) const |
Get the calculated spectrum. More... | |
void | getRGB (double &r, double &g, double &b) const |
Get the color associated with the calculated spectrum in RGB color space. More... | |
void | getHSV (double &h, double &s, double &v) const |
Get the color associated with the calculated spectrum in HSV color space. More... | |
double | getOpacity () const |
Get the opacity of the color associated with the calculated spectrum. More... | |
int | getNLayers () const |
Get the number of layers currently in the nanoparticle. More... | |
NPSpec::NanoparticleShape | getShape () const |
Get the current shape of the nanoparticle. More... | |
NPSpec::SpectraType | getSpectraType () const |
Get the current spectra type of the nanoparticle. More... | |
NPSpec::SpectraProperty | getSpectraProperty () const |
Get the current spectra property of the nanoparticle. More... | |
double | getSphereRadius () const |
Get the current sphere radius. More... | |
double | getEllipsoidZRadius () const |
Get the current Z-component of the ellipsoid radius in nm. More... | |
double | getEllipsoidXYRadius () const |
Get the current XY-component of the ellipsoid radius in nm. More... | |
double | getSphereLayerRelativeRadius (int layer_num) const |
Get the sphere's relative radius in nm of a particular layer. More... | |
double | getEllipsoidLayerZRelativeRadius (int layer_num) const |
Get the ellipsoid's relative radius of a particular layer in the Z-direction. More... | |
double | getEllipsoidLayerXYRelativeRadius (int layer_num) const |
Get the ellipsoid's relative radius of a particular layer in the XY-direction. More... | |
std::string | getLayerMaterial (int layer_num) const |
Get the material for the given layer. More... | |
int | getLayerIndex (int layer_num) const |
Get the index corresponding to the material for the given layer. More... | |
int | getIncrement () const |
Get the increment used when calculating the spectrum. More... | |
double | getPathLength () const |
Get the Beer's law path length in centimeters. More... | |
double | getConcentration () const |
Get the Beer's law concentration in molarity. More... | |
bool | getSizeCorrect () const |
Get the size correction flag. More... | |
double | getMediumRefractiveIndex () const |
Get the refractive index of the surrounding medium. More... | |
void | setNLayers (int nlay) |
Sets the number of layers currently in the nanoparticle. More... | |
void | setShape (NPSpec::NanoparticleShape npshape) |
Sets the current nanoparticle shape. | |
void | setSpectraType (NPSpec::SpectraType stype) |
Sets the type of spectrum to calculate. More... | |
void | setSpectraProperty (NPSpec::SpectraProperty spec) |
Sets the property of the spectrum for which to calculate. More... | |
void | setSphereRadius (double rad) |
Sets the current spherical radius in nm. More... | |
void | setEllipsoidRadius (double zrad, double xyrad) |
Sets the current ellipsoid radius in nm. More... | |
void | setSphereLayerRelativeRadius (int layer_num, double rrad) |
Sets the spherical relative radius for the given layer. More... | |
void | setEllipsoidLayerRelativeRadius (int layer_num, double zrrad, double xyrrad) |
Sets the ellipsoid relative radiis for the given layer. More... | |
void | setLayerMaterial (int layer_num, std::string mat) |
Sets the material for a particular layer of the nanoparticle. More... | |
void | setIncrement (int i) |
Sets the increment used when calculating the spectrum. More... | |
void | setPathLength (double len) |
Sets the Beer's law path length in centimeters. More... | |
void | setConcentration (double conc) |
Sets the Beer's law concentration in molarity. More... | |
void | setSizeCorrect (bool corr) |
Sets whether size correction will be used in the spectrum calculation or not. More... | |
void | setMediumRefractiveIndex (double mref) |
Sets the refractive index of the surrounding medium. More... | |
Class to hold nanoparticle definition and calculate its spectrum. The interface for Python is the same as this C++ API.
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
A maximum of 10 nanoparticle layers is allowed (layer numbers are 1 - 10).
Nanoparticle::Nanoparticle | ( | ) |
Constructor.
The constructor makes the following initiallizations:
int Nanoparticle::calculateSpectrum | ( | ) |
Calculate the spectra.
This should only be used after the nanoparticle is defined.
std::out_of_range | This is thrown if the number of layers is out of range |
std::invalid_argument | Unknown material or invalid increment |
std::domain_error | Radii, path length, concentration, or refractive index is negative, relative radii don't sum to 1.0 |
double Nanoparticle::getConcentration | ( | ) | const |
Get the Beer's law concentration in molarity.
double Nanoparticle::getEllipsoidLayerXYRelativeRadius | ( | int | layer_num | ) | const |
Get the ellipsoid's relative radius of a particular layer in the XY-direction.
layer_num | The layer of which you wish to know the relative radius. |
std::out_of_range | The layer number is invalid. |
double Nanoparticle::getEllipsoidLayerZRelativeRadius | ( | int | layer_num | ) | const |
Get the ellipsoid's relative radius of a particular layer in the Z-direction.
layer_num | The layer of which you wish to know the relative radius. |
std::out_of_range | The layer number is invalid. |
double Nanoparticle::getEllipsoidXYRadius | ( | ) | const |
Get the current XY-component of the ellipsoid radius in nm.
double Nanoparticle::getEllipsoidZRadius | ( | ) | const |
Get the current Z-component of the ellipsoid radius in nm.
void Nanoparticle::getHSV | ( | double & | h, |
double & | s, | ||
double & | v | ||
) | const |
Get the color associated with the calculated spectrum in HSV color space.
This should only be used after calling getSpectrum.
TODO: Calculate the color for absorbtion and transmission differently.
h | The HUE of the color space, between 0 and 360 (inclusive). |
s | The SATURATION part of the color space, between 0 and 1 (inclusive). |
v | The VALUE part of the color space, between 0 and 1 (inclusive). |
h
, s
, and v
are returned as a 3-tuple, so this would be called as h, s, v = Nanoparticle.getHSV()
. int Nanoparticle::getIncrement | ( | ) | const |
Get the increment used when calculating the spectrum.
int Nanoparticle::getLayerIndex | ( | int | layer_num | ) | const |
Get the index corresponding to the material for the given layer.
layer_num | The material index of which you wish to know the relative radius. |
std::out_of_range | The layer number is invalid. |
std::string Nanoparticle::getLayerMaterial | ( | int | layer_num | ) | const |
Get the material for the given layer.
layer_num | The layer of which you wish to know the relative radius. |
std::out_of_range | The layer number is invalid. |
double Nanoparticle::getMediumRefractiveIndex | ( | ) | const |
Get the refractive index of the surrounding medium.
int Nanoparticle::getNLayers | ( | ) | const |
Get the number of layers currently in the nanoparticle.
double Nanoparticle::getOpacity | ( | ) | const |
Get the opacity of the color associated with the calculated spectrum.
This should only be used after calling getSpectrum.
double Nanoparticle::getPathLength | ( | ) | const |
Get the Beer's law path length in centimeters.
void Nanoparticle::getRGB | ( | double & | r, |
double & | g, | ||
double & | b | ||
) | const |
Get the color associated with the calculated spectrum in RGB color space.
This should only be used after calling getSpectrum.
TODO: Calculate the color for absorbtion and transmission differently.
r | The RED part of the color space, between 0 and 1 (inclusive). |
g | The GREEN part of the color space, between 0 and 1 (inclusive). |
b | The BLUE part of the color space, between 0 and 1 (inclusive). |
r
, g
, and b
are returned as a 3-tuple, so this would be called as r, g, b = Nanoparticle.getRGB()
. NanoparticleShape Nanoparticle::getShape | ( | ) | const |
Get the current shape of the nanoparticle.
bool Nanoparticle::getSizeCorrect | ( | ) | const |
Get the size correction flag.
SpectraProperty Nanoparticle::getSpectraProperty | ( | ) | const |
Get the current spectra property of the nanoparticle.
SpectraType Nanoparticle::getSpectraType | ( | ) | const |
Get the current spectra type of the nanoparticle.
void Nanoparticle::getSpectrum | ( | double | spec[NPSpec::NLAMBDA] | ) | const |
Get the calculated spectrum.
This should only be used after calling calculateSpectrum.
spec | The calculated spectrum. |
spec
is a numpy array that is returned by the function, so this would be called as spec = Nanoparticle.calculateSpectrum()
. double Nanoparticle::getSphereLayerRelativeRadius | ( | int | layer_num | ) | const |
Get the sphere's relative radius in nm of a particular layer.
layer_num | The layer of which you wish to know the relative radius. |
std::out_of_range | The layer number is invalid. |
double Nanoparticle::getSphereRadius | ( | ) | const |
Get the current sphere radius.
void Nanoparticle::setConcentration | ( | double | conc | ) |
Sets the Beer's law concentration in molarity.
conc | When calculating absorption, this is the Beer's law path concentration in molarity to use. The default is \(10^{-6}\) M. |
void Nanoparticle::setEllipsoidLayerRelativeRadius | ( | int | layer_num, |
double | zrrad, | ||
double | xyrrad | ||
) |
Sets the ellipsoid relative radiis for the given layer.
layer_num | The layer of which you wish to change the relative radius. |
zrrad | The new Z-component relative radius of the given layer. The relative radius must be between 0 and 1. |
xyrrad | The new XY-component relative radius of the given layer. The relative radius must be between 0 and 1. |
std::out_of_range | The requested number of layers is illegal. |
std::domain_error | A non-positive relative radius was given. |
void Nanoparticle::setEllipsoidRadius | ( | double | zrad, |
double | xyrad | ||
) |
Sets the current ellipsoid radius in nm.
zrad | The Z-component radius to set for a spherical nanoparticle. |
xyrad | The XY-component radius to set for a spherical nanoparticle. |
std::domain_error | A non-positive radius was given. |
void Nanoparticle::setIncrement | ( | int | i | ) |
Sets the increment used when calculating the spectrum.
i | 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. The default is 1. |
void Nanoparticle::setLayerMaterial | ( | int | layer_num, |
std::string | mat | ||
) |
Sets the material for a particular layer of the nanoparticle.
layer_num | The layer to set the material for. |
mat | String specifying the material to set. The default for all layers is "Ag". |
std::out_of_range | The requested number of layers is illegal. |
std::invalid_argument | Unknown material. |
void Nanoparticle::setMediumRefractiveIndex | ( | double | mref | ) |
Sets the refractive index of the surrounding medium.
mref | The refracive index of the surrounding medium. The default is 1.0. |
void Nanoparticle::setNLayers | ( | int | nlay | ) |
Sets the number of layers currently in the nanoparticle.
nlay | The number of layers you wish the nanoparticle to have. The default is 1. |
std::out_of_range | The requested number of layers is illegal. |
void Nanoparticle::setPathLength | ( | double | len | ) |
Sets the Beer's law path length in centimeters.
len | When calculating absorption, this is the Beer's law path length in cm to use. The default is 1.0 cm. |
void Nanoparticle::setSizeCorrect | ( | bool | corr | ) |
Sets whether size correction will be used in the spectrum calculation or not.
corr | If true size correction will be enabled, if false it will not. The default is false. |
void Nanoparticle::setSpectraProperty | ( | NPSpec::SpectraProperty | spec | ) |
Sets the property of the spectrum for which to calculate.
spec | The property of the spectrum you wish to calculate. |
void Nanoparticle::setSpectraType | ( | NPSpec::SpectraType | stype | ) |
Sets the type of spectrum to calculate.
stype | The type of the spectrum you wish to calculate. |
void Nanoparticle::setSphereLayerRelativeRadius | ( | int | layer_num, |
double | rrad | ||
) |
Sets the spherical relative radius for the given layer.
layer_num | The layer of which you wish to change the relative radius. |
rrad | The new relative radius of the given layer. The relative radius must be between 0 and 1. |
std::out_of_range | The requested number of layers is illegal. |
std::domain_error | A non-positive relative radius was given. |
void Nanoparticle::setSphereRadius | ( | double | rad | ) |
Sets the current spherical radius in nm.
rad | The radius to set for a spherical nanoparticle. |
std::domain_error | A non-positive radius was given. |