Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A problem of "GetAmplitudes" #89

Open
KappaGO opened this issue Feb 22, 2020 · 3 comments
Open

A problem of "GetAmplitudes" #89

KappaGO opened this issue Feb 22, 2020 · 3 comments

Comments

@KappaGO
Copy link

KappaGO commented Feb 22, 2020

Hi! I want to use "GetAmplitudes" for calculating reflection phase, but it can not work. The error is "GetAmplitudes: S4_Layer named 'Above1' not found."
I am confused about this issue and look forward to your help. The code is attached below.

filename1='GetAmplitudes.csv';
file1=io.output(filename1)

--Parameter-------------------------------------
um=1;
nm=um1e-3;
p=568
nm;
tg1=0.8p;
lambda=1550
nm;

S=S4.NewSimulation()
S:SetLattice({p,0},{0,0})
S:SetNumG(100)
S:AddMaterial("Vacuum",{1,0})
S:AddMaterial("Si",{3.483.48,0})
S:AddLayer('Above1',0,'Vacuum')
S:AddLayer('Slab1',tg1,'Vacuum')
S:SetLayerPatternRectangle('Slab1', "Si", {0,0}, 0, {0.29
p,0})
S:AddLayer('Below1',0,'Vacuum')
S:SetExcitationPlanewave({80,0},{0,0},{1,0})
S:SetFrequency(1/lambda)

--Reflection-------------------------------

forw,back = S:GetAmplitudes('Above1',0)
file1:write(forw[1][1],",",forw[1][2],",",back[1][1],",",back[1][2],",")
file1:write("\n")
file1:close()

@jhpark94
Copy link

I also have this issue. I guess 'GetAmplitudes' method is obsolete or broken?

@jiaqi-hu
Copy link

jiaqi-hu commented Jun 4, 2021

--- a/S4/main_lua.c
+++ b/S4/main_lua.c
@@ -2186,7 +2186,7 @@ static int S4L_Simulation_GetAmplitudes(lua_State *L){
 
        layer_name = luaL_checklstring(L, 2, NULL);
        layer = S4_Simulation_GetLayerByName(S, layer_name);
-       if(NULL == layer){
+       if(layer < 0){
                S4L_error(L, "GetAmplitudes: S4_Layer named '%s' not found.", layer_name);
                return 0;
        }
@@ -2204,7 +2204,7 @@ static int S4L_Simulation_GetAmplitudes(lua_State *L){
 
        amp = (double*)malloc(sizeof(double)*8*n);
        Simulation_GetAmplitudes(S,
-               layer,
+               &S->layer[layer],
                luaL_checknumber(L, 3),
                amp, &amp[4*n]);

It seems to be working after making this change.

@almakga
Copy link

almakga commented Sep 2, 2022

--- a/S4/main_lua.c
+++ b/S4/main_lua.c
@@ -2186,7 +2186,7 @@ static int S4L_Simulation_GetAmplitudes(lua_State *L){
 
        layer_name = luaL_checklstring(L, 2, NULL);
        layer = S4_Simulation_GetLayerByName(S, layer_name);
-       if(NULL == layer){
+       if(layer < 0){
                S4L_error(L, "GetAmplitudes: S4_Layer named '%s' not found.", layer_name);
                return 0;
        }
@@ -2204,7 +2204,7 @@ static int S4L_Simulation_GetAmplitudes(lua_State *L){
 
        amp = (double*)malloc(sizeof(double)*8*n);
        Simulation_GetAmplitudes(S,
-               layer,
+               &S->layer[layer],
                luaL_checknumber(L, 3),
                amp, &amp[4*n]);

It seems to be working after making this change.

I did this change, but only GetAmplitudes only works por s-pol. Is the same for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@KappaGO @almakga @jiaqi-hu @jhpark94 and others