-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: test for spheroids (equal to mie for perfect sphere)
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# ----------------------------------------------------- # | ||
# # | ||
# This code is a part of T-matrix fitting project # | ||
# Contributors: # | ||
# L. Avakyan <laavakyan@sfedu.ru> # | ||
# # | ||
# ----------------------------------------------------- # | ||
from __future__ import print_function | ||
from __future__ import division | ||
|
||
import pytest | ||
|
||
from mstm_studio.mstm_spectrum import Material | ||
from mstm_studio.contrib_spheroid import SpheroidSP | ||
from mstm_studio.contributions import MieSingleSphere | ||
|
||
import numpy as np | ||
import os | ||
|
||
|
||
def test_spheroidSP(): | ||
mat_gold = Material(os.path.join('..', 'nk', 'etaGold.txt')) | ||
wls = np.linspace(300, 800, 51) | ||
npsize = 10 # diameter of nanoparticle | ||
sph = SpheroidSP(wavelengths=wls) | ||
sph.set_material(mat_gold, 1.5) | ||
ext_sph = sph.calculate([1, npsize, 1.0]) | ||
|
||
mie = MieSingleSphere(name='mie', wavelengths=wls) | ||
mie.set_material(mat_gold, 1.5) | ||
ext_mie = mie.calculate([1, npsize]) | ||
|
||
assert(np.allclose(ext_sph, ext_mie)) | ||
|