wsshin / maxwellfdfd Goto Github PK
View Code? Open in Web Editor NEWMATLAB-based solver package of Maxwell's equations by the FDFD method
Home Page: http://www.mit.edu/~wsshin/maxwellfdfd.html
MATLAB-based solver package of Maxwell's equations by the FDFD method
Home Page: http://www.mit.edu/~wsshin/maxwellfdfd.html
Hi,
I installed maxwellfdfd ( the "-main" branch) by zip file from the github page.
I'm on a mac running El Capitan and matlab 2015b
I ran two tests and saw two different problems.
First, I ran the "one-liner" on your web page:
[E, H] = maxwell_run(... 'OSC', 1e-9, 1550, ... 'DOM', {'vacuum', 'none', 1.0}, [-1100 1100; -1100 2600; 0 10], 10, BC.p, [100 100 0],... 'OBJ', {'CRC/Ag', 'k'}, ... Box([-1100 -80; 0 1000; 0 10]), ... Box([80 1100; 0 1000; 0 10]), ... 'SRCJ', PlaneSrc(Axis.y, -500, Axis.x), true);
The command ran to completion. I got a figure with a graphic showing the box and the silver slab, but no fields plotted. On inspection the E and H variables are 1x3 cells but the objects in the cells are empty arrays: [].
Second, I ran pointsrc_2d. The following output resulted:
maxwell_run begins. E-field grid type: primary time elapsed: 0.26361 sec in total, 0.26361 sec for initial setup Length Unit: 1.000000e-09 m wvlen = 20, freq = 61.9921 eV materials used: vacuum: eps = [1 0 0;0 1 0;0 0 1], mu = [1 0 0;0 1 0;0 0 1] time elapsed: 0.6788 sec in total, 0.41518 sec for nonuniform grid generation [Nx Ny Nz] = [120 120 1] time elapsed: 1.3 sec in total, 0.62124 sec for eps and mu assignment time elapsed: 1.6603 sec in total, 0.36024 sec for J assignment Error using * Inner matrix dimensions must agree. Error in MatrixEquation/matrix_op (line 104) A = PM * (this.Cm * INV_MU * this.Ce) * PM - this.omega^2 * EPS; Error in solve_eq_direct (line 6) [A, b] = eq.matrix_op(); Error in maxwell_run (line 404) [E, H] = solve_eq_direct(solveropts.eqtype, solveropts.pml, osc.in_omega0(), eps, mu, s_factor, J, M, grid3d); Error in pointsrc_2d (line 10) [E, H, obj_array, src_array, J] = maxwell_run(...
I set a breakpoint at MatrixEquation/matrix_op (line 104) and reran. I noticed that PM
was empty and that this.pm
was also empty.
Do you have any guidance?
Thanks very much.
Brian
How do I get the E field and M field intensity at a particular point?
I am trying to use solve method: "GPU". It pops out following error code: 'The constructor for class 'fds' must return only one output value.' Then, I modified the maxwell_run.m, based on the error code. However, it will pops the error says fds has too many arguments. How can I solve this?
Hi,
I am wondering how can I use the mawellFDFD in order to obtain guided modes for different waveguide structures? Can the modesolver functions be used seperatly and if possible how can I do that?
Thanks
When giving maxwell_run 'SRCJ' an array of source objects, I recieve this error:
Incorrect number of right hand side elements in dot name assignment. Missing [] around left hand side is a likely cause.
changing line 49 from
this.gt = gt
to
if (length(this) == 1)
this.gt = gt;
else
for i = (1:length(this))
this(i).gt = gt;
end
end
end
seems to fix the issue temporarily
Undefined function 'isdiag' for input arguments of type 'double'.
Error in Material/get.hasisoeps (line 120)
truth = isdiag(this.eps) && all(diag(this.eps) == this.eps(1,1));
Error in Material/get.isiso (line 128)
truth = this.hasisoeps && this.hasisomu;
Error in build_system (line 320)
isiso = isiso && mat.isiso;
Error in maxwell_run (line 287)
[osc, grid3d, s_factor, eps, mu, J, M, obj_array, src_array, mat_array, eps_node, mu_node,
isiso] = ...
Error in pointsrc_2d (line 10)
[E, H, obj_array, src_array, J] = maxwell_run(...
Thanks.
is there any way to tilt the cuboidal boxes like if i want to model v shape then how to tilt the box bcoz the box can only be along the coordinate axis
Hi,
I want to evaluate power coupled to a mode. I can evaluate the power at a patch using the provided function for this, but I am not getting too far with the overlap integral between the power and the waveguide mode (some info here https://kb.lumerical.com/en/ref_scripts_overlap.html). Any help is much appreciated.
PS: Also it is not clear where the wavelength dependence of the mode calculation comes in?
Thanks.
The 'Object' class contains parsing errors, cannot be found in the search path of MATLAB, or is hidden by another file with the same name.
There are many search path errors like this, and the installation package is added according to the process, how to deal with this?
In line 81, this.ft is called, which is only initialized in line 95. this.ft should be initialized before line 81.
Hi,
I have been trying to simulate the a photonic crystal waveguide based on your example pc_2d_basic, but with a triangular lattice. However, the non-uniform grid generator sends me the following error:
"dl = 2.250000e+01 is too small or dl = 2.250000e+01 is too large for gap size = 6.500000e+00."
and
"Error using complete_lprim1d (line 100)
grid generation failed between subgrids [-4860 -4837.5 -4815] and [-4808.5 -4786 -4763.5] with target dl
= 22.5: dl = 2.250000e+01 is too small or dl = 2.250000e+01 is too large for gap size = 6.500000e+00."
I tried to change the resolution parameters with little success. Do you have any idea where this could come from?
I solved this issue by switching to a uniform grid. However when I increased the resolution to check the convergence, the intensity of the H field keeps decreasing and does not look like it converges. I did the same with your exemple with the square lattice but the convergence is good. Is there something I am missing?I tested the convergence by probing the field going through the waveguide. I obtained the following values:
0.0414 0.0271 0.0187 0.0141 0.0107
for the set of divider for a: ad=0 25 30 35 40
I used the code below:
ad_ar=20:5:40
for i=1:length(ad_ar)
inspect_only = false;
% Create shapes.
a = 225; % lattice constant
t = 1; % slab thickness
unit=1; % unit of length in meter
% permittivity, r/a, and omegaa/(2pi*c) are taken from p.234 of John D.
% Joannopoulos? et al., "Photonic Crystals: Molding the Flow of Light," 2nd
% edition so that the frequency lies in a band gap.
r = 61%0.27a; % hole radius
wvlen = 950; % omegaa/(2pic) = ka/(2pi) = a/lambda = 0.3
slab_thickness_nm=250;
eps_diel = 3.1783^2;
ad = ad_ar(i); % divider for a
% dd = 10; % divider for d = 2*r
pml_l=6;
mx = 21+pml_l; % half integer puts domain boundary between cylinders and makes PML works better
my = 10.5;
no_hx=pml_l;
no_hy=3
slab_yn = Box([-(mx-no_hx)*a (mx-no_hx)*a; -(my-no_hy)a -1a; 0 t]);%, [a/ad, a/ad, t]);
slab_yp = Box([-(mx-no_hx)*a (mx-no_hx)a; 1a (my-no_hy)*a; 0 t]);%, [a/ad, a/ad, t]);
slab_yn_sh = Box([-(mx-no_hx)a 0a; -1a -0.5a; 0 t]);%, [a/ad, a/ad, t]);
slab_yp_sh = Box([-(mx-no_hx)a 0a; 0.5a 1a; 0 t]);%, [a/ad, a/ad, t]);
slab_yn_fast = Box([0a (mx-no_hx)a; -1a -0.5a; 0 t]);%, [a/ad, a/ad, t]);
slab_yp_fast = Box([0a (mx-no_hx)a; 0.5a 1a; 0 t]);%, [a/ad, a/ad, t]);
rod = CircularCylinder(Axis.z, t, [0 0 t/2], r);%, [2r/dd, 2r/dd, t]);
sh=0.1
rod2 = CircularCylinder(Axis.z, t, [-3a 0 t/2], r);%, [2r/dd, 2r/dd, t]);
rod3 = CircularCylinder(Axis.z, t, [0 sha t/2], r);%, [2r/dd, 2r/dd, t]);
rod4 = CircularCylinder(Axis.z, t, [0 -sha t/2], r);%, [2r/dd, 2r/dd, t]);
bc=BC.p; % Boundary condition, periodic
box=[-mxa mxa; -mya mya; 0 t];% dimension of the simulation
dl=[a/ad a/ad t];
R_pml=1e-4;% target reflectance of the Pml
% Solve the system.
gray = [0.5 0.5 0.5]; % [r g b]
src_loc = [-18a, 0, 0]; % source location
Lpml=[(no_hx-0.5)a no_hya 0];
degpml=2;
[E, H, obj_array, src_array, J] = maxwell_run(...
'OSC',unit , wvlen, ...
'DOM', {'vacuum', 'white', eps_diel},box , dl,bc , Lpml, degpml, R_pml,true, ...
'OBJ', ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yn), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yp), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yn_sh), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yp_sh), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yn_fast), ...
{'dielectric', gray, 1}, periodize_shape(rod, {[a 0 0], [0.5a sqrt(3)a/2 0], [0 0 t]}, slab_yp_fast), ...
'SRCJ', PointSrc(Axis.y,src_loc ), ...
inspect_only);
[power(i)]=powerflux_patch(E, H, Axis.x, 10a)%,[-7a 7*a; 0 1])
save(['wvlentrans_picdiv' num2str(ad) 'wvlen' num2str(wvlen) 'pml_len' num2str(pml_l)],'E','H','obj_array','src_array','J','-v7.3')
save power power ad_ar
end
Hello, I was wondering if anyone has successfully created matlab stantalone executables using the maxwellfdfd toobox. The central problem is including the right file/folders in the compilation instead of using addpath. Any idea on how to proceed? Thanks.
The source.html can't be opened
In multiple examples, which should presumably work, the function poynting.m gives an error:
Undefined function or variable 'array'.
Error in poynting (line 105)
S_scalar2d = Scalar2d(array, grid2d, gt_array, osc,
physQ, ['<', physQ.symbol, '_', char(polarization),
'>'], intercept);
Error in mdm (line 56)
Sx = poynting(Axis.x, E{Axis.y}, E{Axis.z},
H{Axis.y}, H{Axis.z}, Axis.y, 0);
The class 'Object' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the
same name.
Error in build_system (line 101)
obj_dom = Object.empty();
Error in maxwell_run (line 288)
build_system(ge, solveropts.pml, varargin{1:iarg}, pm);
Error in pointsrc_2d (line 10)
[E, H, obj_array, src_array, J] = maxwell_run(...```
I get this when running `pointsrc_2d.m`. All of the installation folders/subfolders are in the search path, so I'm at a bit of a loss here. Any help appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.