def run(Plot, Save): import numpy as np from PyMieSim import Material from PyMieSim.Scatterer import ShellSphere from PyMieSim.Source import PlaneWave from PyMieSim.Detector import Photodiode from PyMieSim.Experiment import ScatSet, SourceSet, Setup, DetectorSet scatKwargs = { 'CoreDiameter': np.geomspace(10e-09, 600e-9, 500), 'ShellWidth': [200e-9, 400e-9], 'CoreIndex': [1], 'ShellIndex': [1.3], 'nMedium': 1 } sourceKwargs = {'Wavelength': [200e-9], 'Polarization': [0]} scatSet = ScatSet(Scatterer=ShellSphere, kwargs=scatKwargs) sourceSet = SourceSet(Source=PlaneWave, kwargs=sourceKwargs) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet) Data = Experiment.Get(Input=['Qsca', 'Qback']) print(Data) if Plot: Data.Plot(y=['Qsca'], x='Core diameter', Scale='lin') if Save: from pathlib import Path dir = f'docs/images/{Path(__file__).stem}' Data.SaveFig(Directory=dir, y=['Qsca'], x='Core diameter', Scale='lin')
def run(Plot, Save): import numpy as np from PyMieSim.Scatterer import Sphere from PyMieSim.Source import PlaneWave from PyMieSim.Detector import Photodiode from PyMieSim.Experiment import ScatSet, SourceSet, Setup, DetectorSet scatKwargs = { 'Diameter': np.linspace(100e-9, 10000e-9, 400), 'Index': [1.4, 1.6], 'nMedium': [1] } sourceKwargs = {'Wavelength': [400e-9], 'Polarization': [0]} scatSet = ScatSet(Scatterer=Sphere, kwargs=scatKwargs) sourceSet = SourceSet(Source=PlaneWave, kwargs=sourceKwargs) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet, DetectorSet=None) Data = Experiment.Get('Qsca') if Plot: Data.Plot(y='Qsca', x='Diameter') if Save: from pathlib import Path dir = f'docs/images/{Path(__file__).stem}' Data.SaveFig(Directory=dir, y='Qsca', x='Diameter')
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup, LPModeSet from PyMieSim import Measure from PyMieSim.Materials import BK7 Wavelength = np.linspace(950e-9, 1050e-9, 300) Diameter = np.linspace(100e-9, 8000e-9, 5) detecSet = LPModeSet(Mode=(1, 1), NA=[0.05, 0.1, 0.2], Phi=-180, Gamma=0, Filter=None, Sampling=300) scatSet = SphereSet(Diameter=Wavelength, Material=BK7, nMedium=1) sourceSet = SourceSet(Wavelength=Wavelength, Polarization=0, Amplitude=1) Experiment = Setup(scatSet, sourceSet, detecSet) Data = Experiment.Get(Measure.Coupling) Data.Plot(y=Measure.Coupling, x='Diameter', Std='Wavelength')
def run(Plot, Save): import numpy as np from PyMieSim import Material from PyMieSim.Scatterer import Sphere from PyMieSim.Source import PlaneWave from PyMieSim.Detector import Photodiode from PyMieSim.Experiment import ScatSet, SourceSet, Setup, DetectorSet scatKwargs = { 'Diameter': 500e-9, 'Material': Material('BK7'), 'nMedium': [1] } sourceKwargs = { 'Wavelength': np.linspace(400e-9, 1000e-9, 50), 'Polarization': [0] } detecKwargs = { 'NA': 0.2, 'Sampling': 300, 'GammaOffset': 0, 'PhiOffset': [0, 30, 60], 'CouplingMode': 'Centered' } detecSet = DetectorSet(Detector=Photodiode, kwargs=detecKwargs) scatSet = ScatSet(Scatterer=Sphere, kwargs=scatKwargs) sourceSet = SourceSet(Source=PlaneWave, kwargs=sourceKwargs) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet, DetectorSet=detecSet) Data = Experiment.Get('Coupling') print(Data) if Plot: Data.Plot(y='Coupling', x='wavelength') if Save: from pathlib import Path dir = f'docs/images/{Path(__file__).stem}' Data.SaveFig(Directory=dir, y='Coupling', x='wavelength')
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup from PyMieSim import Measure scatSet = SphereSet(Diameter=[200e-9, 150e-9], Index=[3, 4], nMedium=[1]) sourceSet = SourceSet(Wavelength=np.linspace(400e-9, 1000e-9, 500), Polarization=[0], Amplitude=[1]) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet) Data = Experiment.Get(Input=[Measure.Qsca]) Data.Mean('Index').Plot(y=Measure.Qsca, x='Wavelength')
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup from PyMieSim.Materials import Gold, Silver, Aluminium from PyMieSim import Measure scatSet = SphereSet(Diameter=np.linspace(1e-09, 800e-9, 300), Material=[Silver, Gold, Aluminium], nMedium=1) sourceSet = SourceSet(Wavelength=400e-9, Polarization=0, Amplitude=1) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet) Data = Experiment.Get(Input=[Measure.Qabs]) Data.Plot(y=[Measure.Qabs], x='Diameter', yLog=True)
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup from PyMieSim.Materials import FusedSilica from PyMieSim import Measure Diameter = np.geomspace(6.36e-09, 10000e-9, 1500) Wavelength = [500e-9, 1000e-9, 1500e-9] scatSet = SphereSet(Diameter=Diameter, Material=FusedSilica, nMedium=1) sourceSet = SourceSet(Wavelength=Wavelength, Polarization=30, Amplitude=1) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet) Data = Experiment.Get(Measure.Qsca) Data.Plot(y=Measure.Qsca, x='Diameter')
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup from PyMieSim import Measure scatSet = SphereSet( Diameter = np.linspace(100e-9, 10000e-9, 400), Index = [1.4, 1.5], nMedium = [1] ) sourceSet = SourceSet( Wavelength = 400e-9, Polarization = [0, 90], Amplitude = 1) Experiment = Setup(ScattererSet = scatSet, SourceSet = sourceSet) Data = Experiment.Get(Input=[Measure.Qext]) Data.Plot(y=Measure.Qext, x='Diameter')
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup, PhotodiodeSet from PyMieSim.Materials import FusedSilica from PyMieSim import Measure scatSet = SphereSet(Diameter=800e-9, Index=np.linspace(1.3, 1.9, 1500), nMedium=1) sourceSet = SourceSet(Wavelength=[500e-9, 1000e-9, 1500e-9], Polarization=30, Amplitude=1) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet) Data = Experiment.Get([Measure.Qsca]) Data.Plot(y=Measure.Qsca, x='Index')
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup from PyMieSim.Materials import Gold, Silver, Aluminium from PyMieSim import Measure Diameter = np.linspace(400e-9, 1400e-9, 50) Wavelength = np.linspace(200e-9, 1800e-9, 100) scatSet = SphereSet(Diameter = Diameter, Material = [Silver, Gold, Aluminium], nMedium = 1 ) sourceSet = SourceSet( Wavelength = Wavelength, Polarization = 0, Amplitude = 1) Experiment = Setup(scatSet, sourceSet) Data = Experiment.Get(Measure.Qabs) Data.Plot(y=[Measure.Qabs], x='Wavelength', yLog=True, Std='Diameter')
def run(Plot, Save): import numpy as np from PyMieSim import Material from PyMieSim.Scatterer import Sphere from PyMieSim.Source import PlaneWave from PyMieSim.Detector import Photodiode from PyMieSim.Experiment import ScatSet, SourceSet, Setup, DetectorSet scatKwargs = { 'Diameter': np.geomspace(6.36e-09, 10000e-9, 500), 'Material': [Material('Silver')], 'nMedium': [1] } sourceKwargs = { 'Wavelength': [400e-9, 900e-9, 1200e-9, 1600e-9], 'Polarization': [0] } scatSet = ScatSet(Scatterer=Sphere, kwargs=scatKwargs) sourceSet = SourceSet(Source=PlaneWave, kwargs=sourceKwargs) Experiment = Setup(ScattererSet=scatSet, SourceSet=sourceSet) Data = Experiment.Get(Input=['Qsca', 'Qabs']) MeanData = Data.Mean('wavelength') print(MeanData) if Plot: Data.Plot(y='Qabs', x='diameter', Scale='log') if Save: from pathlib import Path dir = f'docs/images/{Path(__file__).stem}' Data.SaveFig(Directory=dir, y='Qabs', x='diameter', Scale='log')
def run(): import numpy as np from PyMieSim.Experiment import SourceSet, Setup, CoreShellSet from PyMieSim.Materials import BK7, Silver from PyMieSim import Measure CoreDiameter = np.geomspace(100e-09, 600e-9, 400) Wavelength = [800e-9, 900e-9, 1000e-9] scatSet = CoreShellSet(CoreDiameter = CoreDiameter, ShellDiameter = 800e-9, CoreMaterial = Silver, ShellMaterial = BK7, nMedium = 1 ) sourceSet = SourceSet(Wavelength = Wavelength, Polarization = 0, Amplitude = 1) Experiment = Setup(scatSet, sourceSet) Data = Experiment.Get([Measure.Qsca, Measure.Qback]) Data.Plot(y=[Measure.Qback, Measure.Qsca,], x='CoreDiameter', yLog=True)
def run(): import numpy as np from PyMieSim.Experiment import SphereSet, SourceSet, Setup, PhotodiodeSet from PyMieSim.Materials import BK7 from PyMieSim import Measure Phi = np.linspace(-180, 180, 500) NA = [0.05, 0.1, 0.2, 0.3] detecSet = PhotodiodeSet(NA=NA, Phi=Phi, Gamma=0, Sampling=300, Filter=None) scatSet = SphereSet(Diameter=600e-9, Material=BK7, nMedium=1) sourceSet = SourceSet(Wavelength=900e-9, Polarization=0, Amplitude=1) Experiment = Setup(scatSet, sourceSet, detecSet) Data = Experiment.Get(Measure.Coupling) Data.Plot(y=Measure.Coupling, x='Phi')
def run(): import numpy from PyMieSim.Experiment import SphereSet, SourceSet, Setup, PhotodiodeSet from PyMieSim import Measure from PyMieSim.Materials import BK7 Diameter = numpy.linspace(100e-9, 3000e-9, 600) NA = [0.1, 0.05] scatSet = SphereSet(Diameter=Diameter, Material=BK7, nMedium=1.0) sourceSet = SourceSet(Wavelength=1200e-9, Polarization=90, Amplitude=1) detecSet = PhotodiodeSet(NA=NA, Phi=-180.0, Gamma=0.0, Sampling=600, Filter=None) Experiment = Setup(scatSet, sourceSet, detecSet) Data = Experiment.Get([Measure.Coupling]) Data.Plot(y=[Measure.Coupling], x='Diameter', yLog=False, Normalize=True)
class ExperimentTestCase(unittest.TestCase, BaseStepTest): #___________________________________SPHERE________________________________________________________________ @TestFactory('Initializing coefficient experiment') def step00(self): print("\nUnittest: <Experiment>" + '='*100) scatSet = SphereSet(Diameter = 200e-9, Index = 4, nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(400e-9, 1000e-9, 100), Polarization = 0, Amplitude = 1) self.ExpSet0 = Setup(ScattererSet = scatSet, SourceSet = sourceSet) @TestFactory('Experiment Efficiencies computing') def step01(self): self.Data0 = self.ExpSet0.Get([Measure.Qsca, Measure.A1, Measure.B1]) @TestFactory('DataVisual Array Efficiencies plotting') def step02(self): GUI.invoke_after(PLOTTIME, Close) self.Data0.Plot(y=Measure.Qsca, x='Wavelength') #___________________________________CYLINDER________________________________________________________________ @TestFactory('Initializing photodiode coupling experiment') def step03(self): scatSet = CylinderSet(Diameter = 200e-9, Index = 4, nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(400e-9, 1000e-9, 100), Polarization = 0, Amplitude = 1) DetecSet1 = PhotodiodeSet(NA = 0.1, Phi = 30, Gamma = 0, Filter = None, CouplingMode = "Point", Sampling = 300) self.ExpSet1 = Setup(ScattererSet = scatSet, SourceSet = sourceSet, DetectorSet = DetecSet1) @TestFactory('Experiment photodiode Coupling computing') def step04(self): self.Data1 = self.ExpSet1.Get(Measure.Coupling) @TestFactory('DataVisual Array photodiode Coupling plotting') def step05(self): GUI.invoke_after(PLOTTIME, Close) self.Data1.Plot(y=Measure.Coupling, x='Wavelength') #___________________________________CORESHELL________________________________________________________________ @TestFactory('Initializing LP mode coupling experiment') def step06(self): scatSet = CoreShellSet(CoreDiameter = 100e-9, ShellDiameter = 200e-9, CoreIndex = 1.3, ShellIndex=1.4, nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(400e-9, 1000e-9, 100), Polarization = 0, Amplitude = 1) DetecSet1 = LPModeSet(Mode = (0,1), NA = 0.3, Phi = 0, Gamma = 0, Filter = None, CouplingMode = "Point", Sampling = 300) self.ExpSet2 = Setup(ScattererSet = scatSet, SourceSet = sourceSet, DetectorSet = DetecSet1) @TestFactory('Experiment LP mode Coupling computing') def step07(self): self.Data2 = self.ExpSet2.Get(Measure.Coupling) @TestFactory('DataVisual Array photodiode Coupling plotting') def step08(self): GUI.invoke_after(PLOTTIME, Close) self.Data2.Plot(y=Measure.Coupling, x='Wavelength') #___________________________________SPHERE_MATERIAL________________________________________________________________ @TestFactory('Initializing coefficient experiment [Sphere 1 material]') def step09(self): scatSet = SphereSet(Diameter = 200e-9, Material = BK7, nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(400e-9, 1000e-9, 100), Polarization = 0, Amplitude = 1) self.ExpSet = Setup(ScattererSet = scatSet, SourceSet = sourceSet) @TestFactory('Experiment Efficiencies computing [Sphere 1 material]') def step10(self): self.Data = self.ExpSet.Get(Measure.Qsca) @TestFactory('DataVisual Array Efficiencies plotting [Sphere 1 material]') def step11(self): GUI.invoke_after(PLOTTIME, Close) self.Data.Plot(y=Measure.Qsca, x='Wavelength') #___________________________________SPHERE_2_MATERIAL________________________________________________________________ @TestFactory('Initializing coefficient experiment [Sphere 2 material]') def step12(self): scatSet = SphereSet(Diameter = 200e-9, Material = [BK7, SI], nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(600e-9, 800e-9, 100), Polarization = 0, Amplitude = 1) self.ExpSet = Setup(ScattererSet = scatSet, SourceSet = sourceSet) @TestFactory('Experiment Efficiencies computing [Sphere 2 material]') def step13(self): self.Data = self.ExpSet.Get(Measure.Qsca) @TestFactory('DataVisual Array Efficiencies plotting [Sphere 2 material]') def step14(self): GUI.invoke_after(PLOTTIME, Close) self.Data.Plot(y=Measure.Qsca, x='Wavelength') #___________________________________CYLINDER_2_MATERIAL________________________________________________________________ @TestFactory('Initializing coefficient experiment [Cylinder 2 material]') def step15(self): scatSet = CylinderSet(Diameter = 200e-9, Material = [BK7, SI], nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(600e-9, 800e-9, 100), Polarization = 0, Amplitude = 1) self.ExpSet = Setup(ScattererSet = scatSet, SourceSet = sourceSet) @TestFactory('Experiment Efficiencies computing [Cylinder 2 material]') def step16(self): self.Data = self.ExpSet.Get(Measure.Qsca) @TestFactory('DataVisual Array Efficiencies plotting [Cylinder 2 material]') def step17(self): GUI.invoke_after(PLOTTIME, Close) self.Data.Plot(y=Measure.Qsca, x='Wavelength') #___________________________________CORE/SHELL_2_MATERIAL________________________________________________________________ @TestFactory('Initializing coefficient experiment [Core/Shell 2 material]') def step18(self): scatSet = CoreShellSet(CoreDiameter = 100e-9, ShellDiameter = 200e-9, CoreMaterial = [BK7, SI], ShellMaterial= [BK7], nMedium = 1) sourceSet = SourceSet(Wavelength = np.linspace(600e-9, 800e-9, 100), Polarization = 0, Amplitude = 1) self.ExpSet = Setup(ScattererSet = scatSet, SourceSet = sourceSet) @TestFactory('Experiment Efficiencies computing [Core/Shell 2 material]') def step19(self): self.Data = self.ExpSet.Get(Measure.Qsca) @TestFactory('DataVisual Array Efficiencies plotting [Core/Shell 2 material]') def step20(self): GUI.invoke_after(PLOTTIME, Close) self.Data.Plot(y=Measure.Qsca, x='Wavelength')