ConstantRelative¶
- class dnois.mt.ConstantRelative(name: str, n_relative: float = None, *args, **kwargs)¶
Material with constant refractive index relative to air.
See
Material
for descriptions of parameters.- Parameters:
n_relative (float) – Relative refractive index. Default: 1.
- classmethod from_dict(d: dict) Self ¶
Constructs an instance of
cls
from adict
.- Parameters:
d (dict) – A
dict
typically returned byto_dict()
.- Returns:
An instance of
cls
.
- classmethod load_json(file, **kwargs) Self ¶
Constructs an instance of
cls
through loading JSON from a file, converting it to adict
and then callingfrom_dict()
.- Parameters:
file (str or
pathlib.Path
or file-like object) – The JSON file to load. Either its path (str
orpathlib.Path
) or a file-like object.kwargs – Keyword arguments passed to
json.load()
.
- Returns:
An instance of
cls
.
- n(wl: Real | Tensor, t: float = None, p: float = None, relative: bool = True) Real | Tensor ¶
Computes refractive index.
Note
The result is not dependent on
t
iftemperature_affect_n
isFalse
, similarly forp
andpressure_affect_n
.- Parameters:
wl (float or Tensor) – Wavelength measured in air under given condition.
t (float) – Temperature in degree Celsius. Default:
default_temperature
.p (float) – Pressure in atm. Default:
default_pressure
.relative (bool) – Whether to return relative refractive index or the absolute one otherwise. Default:
True
.
- Returns:
Refractive index.
- n_abs(wl: Real | Tensor, t: float = None, p: float = None) Real | Tensor ¶
Computes absolute refractive index.
See
n()
for description of parameters.
- n_rel(wl: Real | Tensor, t: float = None, p: float = None) Real | Tensor ¶
Computes refractive index relative to
air
.See
n()
for description of parameters.
- save_json(file, **kwargs)¶
Save
self
into a JSON filefile
.- Parameters:
file – The JSON file to save. Either its path (
str
orpathlib.Path
) or a file-like object.kwargs – Keyword arguments passed to
json.dump()
.
- to_dict(keep_tensor: bool = True) dict[str, Any] ¶
Converts
self
into adict
which recursively contains only primitive Python objects.- Return type:
dict
- to_json(**kwargs) str ¶
Converts
self
into a JSON string.- Parameters:
kwargs – Keyword arguments passed to
json.dumps()
.- Return type:
str
- max_wl¶
Maximum wavelength valid for the material.
- min_wl¶
Minimum wavelength valid for the material.
- n_relative: float¶
Relative refractive index.
- name¶
Name of the material.
- ref_t¶
Reference temperature in degree Celsius.