forked from victorliu/S4
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Problem with the python example contained in the installation directory #1
Open
sgrigno2
wants to merge
65
commits into
soamaven:devel
Choose a base branch
from
phoebe-p:devel
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to mimic the instructions from RNP::Eigensystem in file Eigensystems.cpp because MKL lapack cannot handle NULL pointer for the matrix RNP::Eigensystem(n2, NULL, n2, q, NULL, 1, phi, n2, work_, NULL, lwork); //M.P
please edit for the library locations first
fixed bug of undeclared variable
Fix SpectrumSampler in Python extension
Added HPC compliant make file MakefileHPC
…assuming installation via Homebrew
…assuming installation via Homebrew (fix typo)
remove lines causing implicit function declaration errors
Add Apple M1 makefile
checking which flags are necessary for compilation
Fixed S4 build for macOS-arm64
* avoid variable name I in Interpolator.h and main_python.c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
First of all, thanks all for all your work that allows me to have a running S4 on my machine. I am working on the example PythonTest.py contained in the S4 folder. I am experiencing inconsistencies between my results and the one published in the "Highly sensitive biosensors based on all-dielectric nanoresonators" by Bontempi and coauthors.
By running the PythonTest.py without any modifications, I got the same results posted by sajidmc (victorliu#61). The problem is that those results are not the ones shown in the publications mentioned above. Trying to obtain a more fair comparison, I slightly modified the PythonTest.py script. In particular, I have changed the material of the bottom layer from Air to Silicon, increased the number of harmonics from 20 up to 120, and the frequencies resolutions (to guarantee convergencies). I am attaching the modified script and the results as well.
As you can see, S4 cannot reproduce the published results in a lower wavelength range. I am wondering why. I am wondering if you can share your thoughts. Any suggestions are more than welcome!
Below the code
CODE:
import S4
import numpy as np
import matplotlib.pyplot as plt
import time
t = time.time()
p = 0.96
d = 0.73
h = 0.22
S = S4.New(Lattice=((p, 0), (0, p)), NumBasis=100)
Define material
S.SetMaterial(Name='SiO2', Epsilon=(1.45 + 0.0j)**2)
S.SetMaterial(Name='Si', Epsilon=(3.487+0.0j)**2)
S.SetMaterial(Name='Vacuum', Epsilon=(1 + 0j)**2)
Define structure
Top semi-infinite latyer
S.AddLayer(Name='AirAbove', Thickness=0, Material='Vacuum')
#S.AddLayer(Name = 'AirDisp',Thickness = 1, Material = 'Vacuum')
Si-Nnaodisck: Air block plus Si circle
S.AddLayer(Name='Si_disks', Thickness=h, Material='Vacuum')
S.SetRegionCircle(Layer='Si_disks', Material='Si', Center=(0, 0), Radius=d/2)
SiO2 substrate
S.AddLayer(Name='Glass_Below', Thickness=1.99, Material='SiO2')
Semiinfite layer: Semi infite Silicon
S.AddLayer(Name='SiBelow', Thickness=0, Material='Si')
Excitation: plane wave
S.SetExcitationPlanewave(
IncidenceAngles=(
0,# polar angle in [0,180)
0 # azimuthal angle in [0,360)
),
sAmplitude=0,
pAmplitude=1,
Order=0
)
Set options
S.SetOptions(
PolarizationDecomposition=True,
PolarizationBasis='Normal'
)
#wavelength_um = 1;
#freq = 1 / float(wavelength_um);
#S.SetFrequency(freq) #unit 2pic_const / a
#forward,backward = S.GetPowerFlux(Layer = 'AirAbove', zOffset = 0) # reflected power
#forward = S.GetPowerFlux(Layer = 'SiBelow',zOffset = 0)
#print('f='+str(1/freq)+', Power_forward= '+str(forward[0].real)+', Power_backward='+str(-backward.real))
frequency sweep
wavelength_space = np.linspace(1.3, 1.7, 1500)
memory allocation
R = np.zeros((len(wavelength_space)))
T = np.zeros((len(wavelength_space)))
for ii in range(len(wavelength_space)):
lam = wavelength_space[ii]
f = 1 / float(lam)
S.SetFrequency(f)
(forward1, backward1) = S.GetPowerFlux(Layer='AirAbove', zOffset=0)
(forward2, backward2) = S.GetPowerFlux(Layer='SiBelow', zOffset=0)
reflection = -backward1
transmission = forward2
R[ii] = np.real(reflection)
T[ii] = np.real(transmission)
plt.plot(wavelength_space, R, label="R")
plt.plot(wavelength_space, T, label="T")
plt.plot(wavelength_space, T+R, label="T+R")
plt.xlabel('Wavelength (um)')
plt.ylabel('Transmission')
plt.legend(loc="upper left")
plt.ylim(0, 1.1)
plt.show()