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

Fix bug in SetLayer and SetLayerThickness #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hamdav
Copy link

@hamdav hamdav commented Jan 26, 2021

Previously SetLayer and SetLayerThickness had no effect.
This was due to the wrong function being called.
I added the material argument to S4_Simulation_SetLayer in SetLayer
and called Simulation_ChangeLayerThickness in SetLayerThickness.

If you before my commit ran the code at the bottom, it printed

0.69436509370145
0.69436509370145
0.69436509370145

which is clearly wrong, the new thickness should change the result.
After the commit it prints

0.69436509370145
0.70218448995991
0.70206228871898

The lua code to test it was

-- Create a new simulation object
S = S4.NewSimulation()

-- Create the different materials
S:AddMaterial("vacuum", {1.000000,0.000000})
S:AddMaterial("GAAS", {11.38482,0.000000})

-- Add the layers
S:AddLayer('Layer_Above', 0.000000, 'vacuum')
S:AddLayer('gaas_0', 100, 'GAAS')
S:AddLayer('Layer_Below', 0.000000, 'vacuum')

-- Set exitiation and freq
S:SetExcitationPlanewave({0.0,0.0},{1.0, 0.0},{0.0,0.0})
S:SetFrequency(1/1550)

-- Print the results
incidence_flux, reflection_flux_vacuum = S:GetPoyntingFlux('Layer_Above', 0.000000)
reflection_flux_vacuum = (-1) * reflection_flux_vacuum / incidence_flux;
print(reflection_flux_vacuum);

-- Change middle thickness
S:SetLayer('gaas_0', 110, 'GAAS')

-- Print the results
incidence_flux, reflection_flux_vacuum = S:GetPoyntingFlux('Layer_Above', 0.000000)
reflection_flux_vacuum = (-1) * reflection_flux_vacuum / incidence_flux;
print(reflection_flux_vacuum);

-- Change middle thickness
S:SetLayerThickness('gaas_0', 120)

-- Print the results
incidence_flux, reflection_flux_vacuum = S:GetPoyntingFlux('Layer_Above', 0.000000)
reflection_flux_vacuum = (-1) * reflection_flux_vacuum / incidence_flux;
print(reflection_flux_vacuum);

I also found that testing/runtests.sh wasn't functioning, but haven't done anything about that.
Anyway, nice work apart from this :)

Previously SetLayer and SetLayerThickness had no effect.
This was due to the wrong function being called.
I added the material argument to S4_Simulation_SetLayer in SetLayer
and called Simulation_ChangeLayerThickness in SetLayerThickness.
@hamdav
Copy link
Author

hamdav commented Jan 26, 2021

Should solve #74 btw

@WangL3i
Copy link

WangL3i commented Mar 16, 2022

Do I need to recompile after modification?

@WangL3i
Copy link

WangL3i commented Mar 16, 2022

Why do I get an error when recompiling?

@hamdav
Copy link
Author

hamdav commented Mar 16, 2022

Yes you have to recompile after you merge the pull request. I don't know why you get an error, if you want help you'll have to provide more than just "I get an error". And yes the thing you pasted is one of the things I changed

@WangL3i
Copy link

WangL3i commented Mar 16, 2022

Hamdav, thank you for your reply!!! When I tried to recompile again, the error is gone. But a new problem arose during my use, when I use the S:Clone() function, I always get an error of Segmentation fault (core dumped). Have you ever encountered such a problem? This problem has been bothering me for many days.

@WangL3i
Copy link

WangL3i commented Mar 16, 2022 via email

@hamdav
Copy link
Author

hamdav commented Mar 16, 2022

No, sorry. It is usually an indication that you are accessing memory that you are not allowed to access, but it can be many things...

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

Successfully merging this pull request may close these issues.

2 participants