S4 icon indicating copy to clipboard operation
S4 copied to clipboard

Segmentation fault when using patterns

Open DylanMMarques opened this issue 6 years ago • 2 comments

Hi,

I am using the code to model some silica nanopillars. The code works fine if I am not using any pattern but it returns segmentation fault when I use any pattern. I am using python extension. This is the code: import S4 import numpy as np

S = S4.New(Lattice = ((.24,0),(0,.24)), NumBasis=100)

S.AddMaterial(Name='silicon',Epsilon = 12+0.01j) S.AddMaterial(Name='vacuum',Epsilon = 1+0.00j)

S.AddLayer(Name = 'incidentMedium', Thickness = 0, Material = 'vacuum'); S.AddLayer(Name = 'pillar', Thickness = 0.120, Material = 'vacuum')

S.SetRegionRectangle('pillar', 'silicon', (0,0), 0, (0.021, 0.021))

S.AddLayer(Name = 'base', Thickness = 10e-3, Material = 'silicon') S.AddLayer(Name = 'airBellow', Thickness = 0, Material = 'vacuum')

S.SetExcitationPlanewave( IncidenceAngles = (0, 0), pAmplitude = 1 + 0j, sAmplitude = 0 + 0j )

freq = np.linspace(2.5, 1.11111, 10); for freqI in freq: S.SetFrequency(freqI); [tmp,reflection] = S.GetPowerFlux('incidentMedium', 0); transmission = S.GetPoyntingFlux('airBellow',0); print(abs(reflection)**2)

Am I doing something wrong?

Many thanks, Dylan Marques

DylanMMarques avatar Mar 20 '18 18:03 DylanMMarques

Hi Dylan,

There is a small mess in S4 with the python interface. I use the commit "ca2b90". The following script works for me as expected. Hope that helps.

import S4
import numpy as np

S = S4.New(Lattice = ((.24,0),(0,.24)), NumBasis=100)

S.SetMaterial(Name='silicon',Epsilon = 12+0.01j)
S.SetMaterial(Name='vacuum',Epsilon = 1+0.00j)
S.SetMaterial(Name='b',Epsilon = 12+0.00j)

S.AddLayer(Name = 'incidentMedium', Thickness = 0, Material = 'vacuum');
S.AddLayer(Name = 'pillar', Thickness = 0.120, Material = 'vacuum')

S.SetRegionRectangle('pillar', 'silicon', (0,0), 0, (0.021, 0.021))

S.AddLayer(Name = 'base', Thickness = 10e-3, Material = 'silicon')
S.AddLayer(Name = 'airBellow', Thickness = 0, Material = 'vacuum')

S.SetExcitationPlanewave(IncidenceAngles = (0, 0),\
                        pAmplitude = 1 + 0j,\
                        sAmplitude = 0 + 0j)

freq = np.linspace(2.5, 1.11111, 10);
for freqI in freq:
    S.SetFrequency(freqI);
    [f_front,b_front] = S.GetPowerFlux('incidentMedium', 0);
    [f_back, b_back] = S.GetPowerFlux('airBellow',0);
    reflection = -b_front.real/f_front.real
    transmission = f_back.real/f_front.real
    print(reflection)

jmllorens avatar Mar 21 '18 11:03 jmllorens

Hi,

Thanks it helps a lot! I see that there are a lot of small problems with python extension. I think that the best for me is to generate the data with lua and then load in python.

Anyway, many thanks for your suggestion.

DylanMMarques avatar Mar 21 '18 11:03 DylanMMarques