def run(): from PyMieSim.Scatterer import Sphere, Cylinder from PyMieSim.Source import PlaneWave Source = PlaneWave(Wavelength=500e-9, Polarization=0, Amplitude=1) Scat = Sphere(Diameter=1000e-9, Source=Source, Index=1.4, nMedium=1.0) SPF = Scat.SPF(Num=300) SPF.Plot()
def run(Plot, Save): from PyMieSim.Scatterer import Sphere from PyMieSim.Source import PlaneWave Source = PlaneWave(Wavelength=450e-9, Polarization=0, E0=1) Scat = Sphere(Diameter=800e-9, Source=Source, Index=1.4) SPF = Scat.SPF(Num=100) if Plot: SPF.Plot() if Save: from pathlib import Path dir = f'docs/images/{Path(__file__).stem}' SPF.SaveFig(Directory=dir)
class ScattererTestCase(unittest.TestCase, BaseStepTest): Source = PlaneWave(Wavelength = 450e-9, Polarization = 0) photodiode = Photodiode(**DetectorKwarg) lpmode = LPmode(Mode = (0,1), **DetectorKwarg) integratingSphere = IntegratingSphere() #___________________________________SPHERE________________________________________________________________ @TestFactory('Spherical scatterer initialization') def step00(self): print("\nUnittest: <Scatterer>" + '='*100) self.sphere = Sphere(Diameter = 300e-9, Index = 1.4, Source = self.Source) @TestFactory('Spherical Scatterer <S1S2> compute') def step03(self): self.sphere.S1S2(Num=40) @TestFactory('Spherical Scatterer <Stokes> compute') def step04(self): self.sphere.Stokes(Num=40) @TestFactory('Spherical Scatterer <FarFields> compute') def step04(self): self.sphere.FarField(Num=30) @TestFactory('Spherical Scatterer <SPF> compute') def step05(self): self.sphere.SPF(Num=30) @TestFactory('Spherical Scatterer <An & Bn> compute') def step06(self): pass self.sphere.an(3) self.sphere.an() self.sphere.bn(3) self.sphere.bn() self.sphere.cn(3) self.sphere.cn() self.sphere.dn(3) self.sphere.dn() @TestFactory('Spherical Scatterer <S1S2> plotting') def step07(self): GUI.invoke_after(PLOTTIME, Close) self.sphere.S1S2(Num=40).Plot() @TestFactory('Spherical Scatterer <Stokes> plotting') def step08(self): GUI.invoke_after(PLOTTIME, Close) self.sphere.Stokes(Num=40).Plot() @TestFactory('Spherical Scatterer <FarField> plotting') def step09(self): GUI.invoke_after(PLOTTIME, Close) GUI.invoke_after(2*PLOTTIME, Close) self.sphere.FarField(Num=40).Plot() @TestFactory('Spherical Scatterer <SPF> plotting') def step10(self): GUI.invoke_after(PLOTTIME, Close) self.sphere.SPF(Num=40).Plot() @TestFactory('Spherical <Photodiode> coupling') def step11(self): self.photodiode.Coupling(Scatterer = self.sphere) @TestFactory('Spherical <LPmode> coupling') def step12(self): self.lpmode.Coupling(Scatterer = self.sphere) @TestFactory('Spherical <IntegratingSphere> coupling') def step13(self): self.integratingSphere.Coupling(Scatterer = self.sphere) @TestFactory('Spherical Photodiode footprint compute') def step14(self): self.photodiode.Footprint(Scatterer=self.sphere) @TestFactory('Spherical LPmode footprint compute') def step15(self): self.lpmode.Footprint(Scatterer=self.sphere) #___________________________________CYLINDER________________________________________________________________ @TestFactory('Cylindrical scatterer initialization') def step16(self): self.cylinder = Cylinder(Diameter = 300e-9, Index = 1.4, Source = self.Source) @TestFactory('Cylindrical Scatterer <S1S2> compute') def step17(self): self.cylinder.S1S2(Num=40) @TestFactory('Cylindrical Scatterer <Stokes> compute') def step18(self): self.cylinder.Stokes(Num=40) @TestFactory('Cylindrical Scatterer <FarFields> compute') def step19(self): self.cylinder.FarField(Num=30) @TestFactory('Cylindrical Scatterer <SPF> compute') def step20(self): self.cylinder.SPF(Num=30) @TestFactory('Cylindrical Scatterer <An & Bn> compute') def step21(self): self.cylinder.an(3) self.cylinder.an() self.cylinder.bn(3) self.cylinder.bn() @TestFactory('Cylindrical Scatterer <S1S2> plotting') def step22(self): GUI.invoke_after(PLOTTIME, Close) self.cylinder.S1S2(Num=10).Plot() @TestFactory('Cylindrical Scatterer <Stokes> plotting') def step23(self): GUI.invoke_after(PLOTTIME, Close) self.cylinder.Stokes(40).Plot() @TestFactory('Cylindrical Scatterer <FarField> plotting') def step24(self): GUI.invoke_after(PLOTTIME, Close) GUI.invoke_after(2*PLOTTIME, Close) self.cylinder.FarField(40).Plot() @TestFactory('Cylindrical Scatterer <SPF> plotting') def step25(self): GUI.invoke_after(PLOTTIME, Close) self.cylinder.SPF(40).Plot() @TestFactory('Cylindrical <Photodiode> coupling') def step26(self): self.photodiode.Coupling(Scatterer = self.cylinder) @TestFactory('Cylindrical <LPmode> coupling') def step27(self): self.lpmode.Coupling(Scatterer = self.cylinder) @TestFactory('Cylindrical <IntegratingSphere> coupling') def step28(self): self.integratingSphere.Coupling(Scatterer = self.cylinder) @TestFactory('Cylindrical Photodiode footprint compute') def step29(self): self.photodiode.Footprint(Scatterer=self.cylinder) @TestFactory('Cylindrical LPmode footprint compute') def step30(self): self.lpmode.Footprint(Scatterer=self.cylinder) # #___________________________________CORESHELL________________________________________________________________ @TestFactory('Core/Shell scatterer initialization') def step31(self): self.coreShell = ShellSphere(CoreDiameter = 300e-9, ShellWidth=200e-9, CoreIndex = 1.4, ShellIndex=1.5, Source = self.Source) @TestFactory('Core/Shell Scatterer <S1S2> compute') def step32(self): self.coreShell.S1S2(Num=40) @TestFactory('Core/Shell Scatterer <Stokes> compute') def step33(self): self.coreShell.Stokes(Num=40) @TestFactory('Core/Shell Scatterer <FarFields> compute') def step34(self): self.coreShell.FarField(Num=30) @TestFactory('Core/Shell Scatterer <SPF> compute') def step35(self): self.coreShell.SPF(Num=30) @TestFactory('Core/Shell Scatterer <An & Bn> compute') def step36(self): self.coreShell.an(3) self.coreShell.an() self.coreShell.bn(3) self.coreShell.bn() @TestFactory('Core/Shell Scatterer <S1S2> plotting') def step37(self): GUI.invoke_after(PLOTTIME, Close) self.coreShell.S1S2(Num=10).Plot() @TestFactory('Core/Shell Scatterer <Stokes> plotting') def step38(self): GUI.invoke_after(PLOTTIME, Close) self.coreShell.Stokes(40).Plot() @TestFactory('Core/Shell Scatterer <FarField> plotting') def step39(self): GUI.invoke_after(PLOTTIME, Close) GUI.invoke_after(2*PLOTTIME, Close) self.coreShell.FarField(40).Plot() @TestFactory('Core/Shell Scatterer <SPF> plotting') def step40(self): GUI.invoke_after(PLOTTIME, Close) self.coreShell.SPF(40).Plot() @TestFactory('Core/Shell <Photodiode> coupling') def step41(self): self.photodiode.Coupling(Scatterer = self.coreShell) @TestFactory('Core/Shell <LPmode> coupling') def step42(self): self.lpmode.Coupling(Scatterer = self.coreShell) @TestFactory('Core/Shell <IntegratingSphere> coupling') def step43(self): self.integratingSphere.Coupling(Scatterer = self.coreShell) @TestFactory('Core/Shell Photodiode footprint compute') def step44(self): self.photodiode.Footprint(Scatterer=self.coreShell) @TestFactory('Core/Shell LPmode footprint compute') def step45(self): self.footprint = self.lpmode.Footprint(Scatterer=self.coreShell) @TestFactory('Core/Shell Scatterer <Footprint> plotting') def step46(self): GUI.invoke_after(PLOTTIME, Close) self.footprint.Plot()