Coder Social home page Coder Social logo

filipdominec / python-meep-utils Goto Github PK

View Code? Open in Web Editor NEW
53.0 14.0 31.0 7.04 MB

<NEEDS MAJOR UPDATE> Simulations of electromagnetic waves - easier scripting, postprocessing and field export

Home Page: http://www.fzu.cz/~dominecf/meep/

License: GNU General Public License v2.0

Python 83.57% Shell 16.43%
simulation time-domain frequency-domain python-meep metamaterials photonic-crystals electromagnetism fdtd

python-meep-utils's Introduction

python-meep-utils logo

Important note

Since the improvements in meep and its Python bindings in 2018/19, following scripts are rather obsolete. I recommend to refer to the (semi)official meep pages, e.g. https://meep.readthedocs.io/en/latest/ and http://www.simpetus.com/projects.html for up-to-date examples. Filip Dominec 2019

Introduction

MEEP is a library of functions for numerical simulations of how electromagnetic waves propagate and interact with various structures; it is a finite-difference time-domain solver of the Maxwell equations. The simulation is defined by programming, with bindings to C/C++, Scheme, or Python; I chose to use python-meep as Python is a user-friendly language that makes simple simulations (relatively) simple, and really complex ones possible. One can also seamlessly integrate them with powerful Python modules as numpy, scipy, matplotlib and many others.

After I set up several different realistic simulations with python-meep, I noticed that much of the Python code for initialisation, material definition, processing and data output can be shared. I therefore moved such code in the meep_utils.py and meep_materials.py modules.

To demonstrate how to use them to simplify the simulation setup, I accompany these modules with several ready-to-use simulations of various typical problems. I believe the presented scripts can be a great starting point for anybody doing their research on photonic crystals, metamaterials, integrated photonics and nanophotonics, cavity resonators, waveguides, etc.

You are encouraged to clone this repository and to modify the examples to match your needs. I would be very happy if this project helps you with your thesis, homework or any publication. Do not hesitate to contact me if you need some advice, new functionality or if you find a bug.

Filip Dominec, [email protected], 2012 - 2016

Examples using the simulation scripts

Usually, everything you need to run an example is to change to its directory, and launch ./batch.sh. In a multiprocessing environment, it is recommended to launch it like export NP=4; ./batch.sh.

example_metamaterial_s_parameters

Uses scatter.py and effparam.py to retrieve the effective behaviour of a metamaterial using the Nichols-Ross-Weir (s-parameters) method. Some of these examples are scans through a parameter of the structure.

example_frequency_domain_solver

Runs scatter.py multiple times in frequency-domain, and then compares the results to the classical Fourier-transformed time-domain simulation

example_current_driven_homogenisation

Using cdh.py, plot_cdh.py, computes and plots data for current-driven homogenization; compares them with those obtained from s-parameters

example_angle_frequency_scan

Sets up both the source and the monitor planes such that they have a growing phase in space (done simply by harmonic modulation of the source amplitude). This way, an oblique wave is excited and recorded. Using arccosine, the angle can be computed from our knowledge of the frequency and the transverse component of the wavevector. By several time-domain simulations with different transverse wavevectors, we can efficiently build a 2D map of angle- and frequency-dependent reflectance of a sample.

example_ringdown_cylindrical_cavity

The simulation in cylindrical_cavity.py defines a metallic cylindrical cavity, excites the field by a short pulsed source, and analyzes the ringdown to search for all modes.

Then the data are processed by ringdown_analysis.py and a comparison of Fourier transform, filter-diagonalisation (harminv) method and the textbook analytic solution is plotted.

Optionally, by uncommenting the bottom half of example_ringdown_cylindrical_cavity/batch.sh, the ringdown analysis can be used to search for terahertz resonances in experimental transmission water vapour. Quite a good match is obtained, which means that harminv works as expected.

example_surface_plasmons

Uses plasmons.py: A small aperture in a thin metal sheet couples incident light to surface plasmons.

If the film is surrounded by two media with similar index of refraction, circular interference pattern can be observed between the symmetric and antisymmetric plasmon modes. A different (hyperbolic) interference pattern can be obtained when the plasmons are coupled by two holes.

  • TODO add support for metal/diel substrate,
  • and try to show the sym-asym interference

example_aperture_near-field_microscope/

  • detection of field behind the aperture, normalized against free reference
  • anisotropic permittivity of the dielectric sphere

example_dielectric_bars_width_scan/

  • TODO

example_dielectric_slab_oblique_incidence/

  • TODO , c.f. transfer-matrix

example_refraction_on_MM_wedge_2D/ - defines a wedge of a 2-D rod array (studied earlier both as a photonic crystal and a metamaterial), and by the means of spatial Fourier transform, analyzes how a beam is refracted depending on its frequency. Compares the result with the s-parameter retrieval method.

  • TODO implement seamless 2-D support

example_nonlinear_Kerr_focusing/ - demonstrates a source with custom spatial shape, which launches a focused Gaussian beam. Different amplitudes are scanned to show how the nonlinear medium changes the beam and eventually allows filament formation.

  • TODO implement nonlinearity, test out

example_SPDC/

  • spdc.py - TODO

Related resources

Technical notes

Installation procedure

The scripts require working python-meep environment, recommended compilation procedure is supplied in the python-meep-install.py script which is hosted here: https://github.com/FilipDominec/python-meep-install

Some scripts use the matplotlib's binding for LaTeX for nicer plots. You may either install the dependencies using sudo apt-get install -y texlive-latex-extra dvipng, or modify the scripts to avoid using the latter.

The procedure is tested on Debian-based Linux distributions. You may have to manually modify it if your system differs. Please read the script for details.

General modules and other files

  • meep_utils.py - the main module with routines useful for python-meep simulations
  • meep_materials.py - module containing realistic definition of materials used
  • README.md - this file
  • LICENSE - General Public License
  • metamaterial_models.py - different metamaterial models (that can be shared by other scripts)
  • plot_scan_as_contours.py - if multiple simulations are run as a parametric scan, this allows to present all results in a single contour plot
  • harminv_wrapper.py - allows to simply use filter diagonalisation method from Python

Troubleshooting - what may happen and what it means

Outright errors

  • terminate called after throwing an instance of 'Swig::DirectorMethodException', and simulation fails with an ugly call trace
    • Perhaps you left some run-time error in the structure definition: The eps() method is a callback, so a runtime error will not be handled by Python's usual "friendly" report of where the error is. To test this function prior to running MEEP's callback, put meep_utils.testmaterials() at the end of the model's initialization, which will help to obtain a reasonable Python report to find the problem.
    • If meep_utils.testmaterials() did not help, check other possible callback routines.
    • Make sure to never set the eps variable within the AbstractMeepModel class, since this name is reserved for MEEP callback.
  • Simulation hard-crashes during model initialization with the 'memory not mapped' error (observed with Matplotlib 1.5.1 on Ubuntu 16.10)
    • This happens at the point when matplotlib tries to plot the permittivity spectrum, and to place a label at some high-frequency position like 10^16
    • I reported this error here matplotlib/matplotlib#6984; the solution is in installing a newer fixed version of matplotlib. I suggest picking the freshest one from git: http://matplotlib.org/faq/installing_faq.html#source-install-from-git
    • One little annoyance is that uninstalling the original python-matplotlib package one also has to uninstall paraview. Compile the new version, then install paraview back and everything will be fine.
  • Simulation aborts with lorentzian unstable although the medium passed the meep_utils.testmaterials() function
    • The compiled-in check for Lorentzian stability in MEEP is overly prudent; it sometimes aborts a simulation that would be completely stable. You may either change the material model as MEEP suggests.
    • I consider this to be just an unfixed bug, see also the discussion https://github.com/stevengj/meep/issues/12. So even better is to change the MEEP source code to bypass the abort in function lorentzian_unstable in src/susceptibility.cpp and recompile it. My branch of MEEP does it.
  • The time-domain simulation aborts when I try to define a material with a negative permittivity
    • The frequency-independent part of permittivity (i.e. permittivity without Lorentzian oscillators) in the time-domain solver can never be defined negative. In fact its minimum value is roughly 0.87 by default, this number is determined by the Courant factor used. For mathematical discussion, see https://github.com/stevengj/meep/issues/12. If you need a medium with negative permittivity, resort to the frequency-domain solver, or define a proper Drude-Lorentz model.
  • The frequency-domain simulation does not converge when I try to define a material with a negative permittivity
    • The frequency-domain usually fails to converge in the infrared or optical range, where permittivity of metals is a small negative (complex) number. Defining the same metals in microwave simulations appears fine and converges. This situation is somewhat hard to compute with MEEP; you may try to reformulate your problem using Lorentz-Drude model and run a time-domain simulation with a narrow-band source.
    • Changing the resolution or running few time-domain steps before running frequency-domain solver may also help.
  • AttributeError: 'unicode' object has no attribute 'shrink'
    • Try disabling LaTeX in Matplotlib.
  • HDF5-DIAG: Error detected in HDF5 (...) unable to open file:w
    • perhaps you try to export the fields twice to the same file?
  • ValueError: width and height must each be below 32768
    • this seems like a bug in certain versions of Matplotlib, try disabling labels

Invalid or weird results

  • Exported figures show no fields and are black
    • This means that infinite values or not-a-numbers ("NaN") resulted from the simulation. This is perhaps due to simulation being unstable for some reason. If you use the AmplitudeMonitorPlane objects, you will automatically get the amplitudes_time_domain.png plot for diagnostics. It should show whether the fields are exponentially growing instead of decaying.
  • The simulation seems to be stable, but no valid data are plotted - the results seem rather random
    • Did you use the same polarisation (field-component) of the source and detectors, etc.? If not, you obviously get numerical noise from normalization of tiny values by other tiny values. Check the order of magnitude for the source duration and simulation. Make sure the source has broad enough spectrum to cover all frequencies of interest.
  • Using AmplitudeMonitorPlane, the retrieved transmission or reflection is over unity
    • If this happens in the form of characteristic "ringing" in spectra around narrow resonances, it may often be due to spectral leakage. Prolonging the simulation time or using a lossy medium usually helps.
    • Make sure to check the time-domain exported fields if they decay in exponential manner as they should, or do something unexpected.
  • Frequency-domain and time-domain results are different
    • In fact, the results were different by few percent when I made comparisons, and I do not know why.
    • Either the frequency-domain solver did not converge correctly, or the time-domain solver had to modify the material definition to make the simulation stable. In either case, read the simulation printouts what happened.

Confusing printouts

  • Python's tracebacks are double printed, and their lines are randomly mixed.
    • Run the simulation in single process if you need clear debugging messages.
  • Simulation gives correct results, but at the end complaints that mpirun has exited ... without calling "finalize"
    • This is harmless. I did not find any way to prevent the message in python-meep.
  • Simulation writes about 'epsilon averaging' although I did not explicitly enable it.
    • This appears to be a little bug of python-meep; no matter what it writes, the averaging is probably off anyway

TODO

  • scatter.py, cdh and others should output sim_param in the header (moreover CDH has weird header!!)

  • move Kx, Ky out of the model parameters

  • put the models into separate module

  • sync harminv from its module with meep_utils, and remove from the latter

  • effparam.py does not cope with "plot_freq_max=None" anymore? -- fix

  • why I do not see interference of sym/asym plasmons in the example? wrong metal model!

  • plot_contour to read any column from direct sim output / effparam

  • [ ]

  • stability of metals - try to increase 'gamma' until it goes unstable; map the parameter!

  • from scipy.misc import imsave; imsave('../docs/static/tutorial-epsilon.png', -N.rot90(epsilon)) ?

  • Use average_field_function instead of my own averaging!

  • use synchronize_fields() instead of shifting H(t) ? - benchmark

  • test averaging on SRR

  • test the Fresnel inversion algorithm on dispersive dielectric slabs

  • fix the stupid SWIG bug: http://sourceforge.net/donate/?user_id=246059#recognition

  • resonant modes extraction via HarmInv, done in a branched file

  • optimize the structure using D.E (http://inspyred.github.com) or CMA-ES

  • mode separation on the user-defined ports

  • add examples (tests / case study?):

    • waveguide-splitter
    • metamaterial parameters of dielectric sphere in wire mesh
    • a split-ring resonator and current-driven homogenisation
    • surface-plasmons
    • surface-plasmons on thin-metal
    • thin-gold-film-transmission
    • plasmonic resonance in gold nanoparticles
    • resistive-metal strips
    • extraordinary transmission
    • Kerr nonlinearity and self-focusing
    • scattering SNOM microscope
    • oblique-wave fabry-pérot resonances, comparison with analytic solution
    • resonances in cylinder cavity, application of harminv and comparison with analytic
    • modeling spontaneous parametric down-conversion
  • check what functionality is available on Windows (could add the procedure to compile python-meep for Win)

    • probably no run_bash call will work - slice export will fail on Windows?
  • currently, the materials are composed into a structure only for the permittivity (static value + Lorentzians), shall we do this also for permeability? And for nonlinear effects etc.?

  • compress video with something like: ffmpeg -i input -c:v libx264 -preset veryslow -qp 0 output.mkv

  • solve the following message Progress 0.90 of expected total 107 s CMD: cd 'SphereWire_comment=TiO$_2$ spheres only_resolution=5.000e-06_radius=3.000e-05'; h5tovtk 'EPS_at_t0.000e+00.h5:eps' '-t 0' -o 'EPS_at_t0.000e+00.vtk' CMD: cd 'SphereWire_comment=TiO$_2$ spheres only_resolution=5.000e-06_radius=3.000e-05'; rm 'EPS_at_t0.000e+00.h5' Traceback (most recent call last): File "../../scatter.py", line 113, in eps1=getattr(model, 'mon1eps', 1), eps2=getattr(model, 'mon2eps', 1)) ## enable monitors inside dielectrics File "/home/filip/python-meep-utils/meep_utils.py", line 902, in get_s_parameters Ex1, Hy1, Ex2, Hy2 = map(lambda x: np.append(x, np.zeros(target_len - len(Ex1))), (Ex1, Hy1, Ex2, Hy2)) File "/home/filip/python-meep-utils/meep_utils.py", line 902, in Ex1, Hy1, Ex2, Hy2 = map(lambda x: np.append(x, np.zeros(target_len - len(Ex1))), (Ex1, Hy1, Ex2, Hy2)) TypeError: 'numpy.float64' object cannot be interpreted as an index

python-meep-utils's People

Contributors

filipdominec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-meep-utils's Issues

MPI synchronisation freezes in ca 1% of simulations

There is some deadlock in the python-meep HDF export or sync() function; I am suspicious it is the multiprocessing communication. The simulation silently hangs after the FDTD timestepping is finished and has to be terminated manually.

Observed on Ubuntu 16.04 with openmpi 1.10.2. This never happened to me on previous versions of Ubuntu, although I used a very similar installation procedure for python meep (https://github.com/FilipDominec/python-meep-install).

Currently, I have no clue how to resolve this except for debugging openmpi, which is beyond my capabilities.

Incompatibility with HDF5 lib in Fedora23+

Running example_metamaterial_s_parameters/yslit_xcomparison_d20/batch.sh results in:

Info    Adding material: Gold with 1 oscillator(s); (eps @ 1.00e+12 Hz = -20443.0+281018.263j)
    Simulation time: 3.500000e-10 [s] = 1.049274e-01 time units
Traceback (most recent call last):
  File "../../scatter.py", line 92, in <module>
    for slice_ in slices: slice_.poll(f.time()/c)
  File "/home/dominecf/python-meep-utils/meep_utils.py", line 818, in poll
Traceback (most recent call last):
  File "../../scatter.py", line 92, in <module>
    self.field.output_hdf5(component, self.volume, self.openfile, 1) 
  File "/usr/lib64/python2.7/site-packages/meep_mpi.py", line 4350, in output_hdf5
    for slice_ in slices: slice_.poll(f.time()/c)
  File "/home/dominecf/python-meep-utils/meep_utils.py", line 818, in poll
    self.field.output_hdf5(component, self.volume, self.openfile, 1) 
  File "/usr/lib64/python2.7/site-packages/meep_mpi.py", line 4350, in output_hdf5
    return _meep_mpi.fields_output_hdf5(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'fields_output_hdf5'.
  Possible C/C++ prototypes are:
    meep::fields::output_hdf5(meep::h5file *,char const *,int,meep::component const *,meep::field_function,void *,int,meep::volume const &,bool,bool)
    meep::fields::output_hdf5(meep::h5file *,char const *,int,meep::component const *,meep::field_function,void *,int,meep::volume const &,bool)
    meep::fields::output_hdf5(meep::h5file *,char const *,int,meep::component const *,meep::field_function,void *,int,meep::volume const &)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_function,void *,meep::volume const &,meep::h5file *,bool,bool,char const *,bool)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_function,void *,meep::volume const &,meep::h5file *,bool,bool,char const *)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_function,void *,meep::volume const &,meep::h5file *,bool,bool)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_function,void *,meep::volume const &,meep::h5file *,bool)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_function,void *,meep::volume const &,meep::h5file *)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_function,void *,meep::volume const &)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_rfunction,void *,meep::volume const &,meep::h5file *,bool,bool,char const *)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_rfunction,void *,meep::volume const &,meep::h5file *,bool,bool)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_rfunction,void *,meep::volume const &,meep::h5file *,bool)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_rfunction,void *,meep::volume const &,meep::h5file *)
    meep::fields::output_hdf5(char const *,int,meep::component const *,meep::field_rfunction,void *,meep::volume const &)
    meep::fields::output_hdf5(meep::component,meep::volume const &,meep::h5file *,bool,bool,char const *)
    meep::fields::output_hdf5(meep::component,meep::volume const &,meep::h5file *,bool,bool)
    meep::fields::output_hdf5(meep::component,meep::volume const &,meep::h5file *,bool)
    meep::fields::output_hdf5(meep::component,meep::volume const &,meep::h5file *)
    meep::fields::output_hdf5(meep::component,meep::volume const &)
    meep::fields::output_hdf5(meep::derived_component,meep::volume const &,meep::h5file *,bool,bool,char const *)
    meep::fields::output_hdf5(meep::derived_component,meep::volume const &,meep::h5file *,bool,bool)
    meep::fields::output_hdf5(meep::derived_component,meep::volume const &,meep::h5file *,bool)
    meep::fields::output_hdf5(meep::derived_component,meep::volume const &,meep::h5file *)
    meep::fields::output_hdf5(meep::derived_component,meep::volume const &)

passing params on command line

Hello,

Congrats for your work on this!

I'm trying to use cylindrical_cavity.py as a starting point for a simulation.
I ran the corresponding example "ringdown_cylindrical_cavity" with the batch.sh script, and it seems to do fine.
There is however this error message:

File "../cylindrical_cavity.py", line 14, in <module>
    sim_param, model_param = meep_utils.process_param(sys.argv[1:])
ValueError: need more than 0 values to unpack

due to the fact that the python script is called without argument I presume. Anyway, I get some results.

Now when I take the cylindrical_cavity.py script, and try to run it on the command line without argument, I have the same error message, and no output data at all.
If I try to pass some argument on the command line, like ./cylindrical_cavity X=1c Y=1G (X and Y being some string, one of my question is actually very basic: where do I find a parameter list?):

  • if I pass one argument, I get:
Traceback (most recent call last):
  File "./cylindrical_cavity.py", line 14, in <module>
    sim_param, model_param = meep_utils.process_param(sys.argv[1:])
ValueError: need more than 1 value to unpack
  • if I pass 2 arguments, I get:
Traceback (most recent call last):
  File "./cylindrical_cavity.py", line 51, in <module>
    model = HollowCyl_model(**model_param)
TypeError: type object argument after ** must be a mapping, not str

I don't understand those errors, neither am I sure of understanding what the parameters can be and which one are necessary.

also, the incriminated line in cylindrical_cavity.py is:

sim_param, model_param = meep_utils.process_param(sys.argv[1:])

and in meep_utils.py I see:

def process_param(args):#{{{                  %% TODO include this code into Abstr..Model.init()
    """ Parse command-line parameters and store them as attributes of the model """
    model_param = {}
    for namevalue in args:
        name, value = namevalue.split("=")
        model_param[name] = phys_to_float(value)
    return model_param

Isn't it odd that process_param returns only one dic, while its call in cylindrical_cavity.py requests two dics as outputs ? (sim_param and model_param)

'No module named 'meep_mpi'

hi, thanks for your kindness
I run this code and get 'No module named 'meep_mpi' '
but I can't install it correct
how can I deal with it?

h5utils not compiling with Cygwin

I've been trying to install Meep and Python-Meep on Win7 with Cygwin by following the tutorial linked below:
http://novelresearch.weebly.com/installing-meep-in-windows-8-via-cygwin.html

I've also had a look at two other tutorials:
https://www.mail-archive.com/[email protected]/msg03793.html
http://thread.gmane.org/gmane.comp.science.electromagnetism.meep.general/3428

All three seem to be similar but with small differences. I'm unsure as to which method will best install Meep on a Windows 7 platform. When following the 1st tutorial I didn't get past the first hurdle. When compiling h5utils, the following error was the result:

make[1]: Entering directory '/cygdrive/c/cygwin/usr/local/h5utils-1.12.1'
gcc -DHAVE_CONFIG_H -I. -I/usr/local/include -g -O2 -MT writepng.o -MD -MP -MF .deps/writepng.Tpo -c -o writepng.o writepng.c
writepng.c: In function ‘writepng’:
writepng.c:312:24: error: dereferencing pointer to incomplete type ‘png_struct {aka struct png_struct_def}’
if (setjmp(png_ptr->jmpbuf)) {
^
writepng.c:437:19: error: dereferencing pointer to incomplete type ‘png_info {aka struct png_info_def}’
free(info_ptr->palette);
^
make[1]: *** [Makefile:426: writepng.o] Error 1
make[1]: Leaving directory '/cygdrive/c/cygwin/usr/local/h5utils-1.12.1'
make: *** [Makefile:278: all] Error 2

The author dismisses any errors with h5utils in this tutorial saying that MatLab is more capable for processing. However, it seems that due to this failure h5topng is not found and without having access to MatLab, my outputs are useless.

When trying to run 'ring.ctl' from the Meep/examples folder I also get the following:

creating output file "./ring-eps-000000.00.h5"...
Backtrace:
In /pub/devel/guile/yaakov/guile-2.0.14-1.i686/src/guile-2.0.14/module/ice-9/boot-9.scm:
160: 12 [catch #t #<catch-closure 801d0950> ...]
In unknown file:
?: 11 [apply-smob/1 #<catch-closure 801d0950>]
In /pub/devel/guile/yaakov/guile-2.0.14-1.i686/src/guile-2.0.14/module/ice-9/eval.scm:
432: 10 [eval # #]
432: 9 [eval # #]
In unknown file:
?: 8 [primitive-load "ring.ctl"]
In /pub/devel/guile/yaakov/guile-2.0.14-1.i686/src/guile-2.0.14/module/ice-9/eval.scm:
432: 7 [eval # #]
In /pub/devel/guile/yaakov/guile-2.0.14-1.i686/src/guile-2.0.14/module/ice-9/boot-9.scm:
710: 6 Exception thrown while printing backtrace:
ERROR: In procedure delete-meep-volume: Wrong type argument in position 1: #<finalized smob 80447d00>
ERROR: In procedure %run-finalizers:
ERROR: In procedure delete-meep-volume: Wrong type argument in position 1: #<finalized smob 80447ef0>
Some deprecated features have been used. Set the environment
variable GUILE_WARN_DEPRECATED to "detailed" and rerun the
program to get more information. Set it to "no" to suppress
this message.

Any thoughts on what might be happening with Meep would be very helpful. It's been a number of days trying to get it to install correctly on both Windows and Ubuntu.

Emma

numpy.float64 object cannot be interpreted as an index

Simulations in the example_metamaterial_s_parameters/SphereWire_principles terminate with error

Traceback (most recent call last):
  File "../../scatter.py", line 113, in <module>
    eps1=getattr(model, 'mon1eps', 1), eps2=getattr(model, 'mon2eps', 1))               ## enable monitors inside dielectrics
  File "/home/dominecf/python-meep-utils/meep_utils.py", line 902, in get_s_parameters
    Ex1, Hy1, Ex2, Hy2  =  map(lambda x: np.append(x, np.zeros(target_len - len(Ex1))), (Ex1, Hy1, Ex2, Hy2))
  File "/home/dominecf/python-meep-utils/meep_utils.py", line 902, in <lambda>
    Ex1, Hy1, Ex2, Hy2  =  map(lambda x: np.append(x, np.zeros(target_len - len(Ex1))), (Ex1, Hy1, Ex2, Hy2))
TypeError: 'numpy.float64' object cannot be interpreted as an index

However, the FDTD computation finishes correctly, as seen from the plotted E-field curve.

port to new Python API?

Hi @FilipDominec, now that we have a Python API integrated into the main Meep repo, it would be great if you could port some of the examples to the new high-level API.

(The high-level API is built on top of a SWIG-generated low-level API that mirrors the C++ API. For example, it allows the geometry to be specified in terms of geometric objects — and, recently, GDSII CAD files — with fast subpixel averaging. There are also other new features like mode decomposition.)

Let us know if there is anything we can do to help integrate your efforts. cc @ChristopherHogan, who wrote much of the new Python API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.