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

error message output in Jupyter notebook #907

Closed
oskooi opened this issue Jun 7, 2019 · 1 comment · Fixed by #953
Closed

error message output in Jupyter notebook #907

oskooi opened this issue Jun 7, 2019 · 1 comment · Fixed by #953

Comments

@oskooi
Copy link
Collaborator

oskooi commented Jun 7, 2019

The following example which intentionally involves a bug related to a missing direction parameter in the FluxRegion object causes a Jupyter notebook kernel failure with the message: The kernel appears to have died. It will restart automatically..

import meep as mp

cell = mp.Vector3(16,16,0)
geometry = [mp.Block(mp.Vector3(12,1,mp.inf),
                     center=mp.Vector3(-2.5,-3.5),
                     material=mp.Medium(epsilon=12)),
            mp.Block(mp.Vector3(1,12,mp.inf),
                     center=mp.Vector3(3.5,2),
                     material=mp.Medium(epsilon=12))]
pml_layers = [mp.PML(1.0)]
resolution = 10

sources = [mp.Source(mp.ContinuousSource(wavelength=2*(11**0.5), width=20),
                     component=mp.Ez,
                     center=mp.Vector3(-6,-3.5),
                     size=mp.Vector3(1,1.2))]

sim = mp.Simulation(cell_size=cell,
                    boundary_layers=pml_layers,
                    geometry=geometry,
                    sources=sources,
                    resolution=resolution)

### error: missing 'direction' parameter in FluxRegion
tran = sim.add_flux(1/2*(11**0.5), 0, 1, mp.FluxRegion(center=mp.Vector3(3.5,2), size=mp.Vector3(2,1.2)))

sim.run(until=200)

The error message from Meep which describes the cause does not appear in the notebook but rather in the terminal which launched the notebook:

meep: Could not determine normal direction for given grid_volume.
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0

It would be useful, for debugging purposes, etc., to have all error messages appear directly within the notebook.

@stevengj
Copy link
Collaborator

stevengj commented Jun 11, 2019

For MPI jobs, I think we may need to continue calling MPI_Abort to make sure that all the processes stop working on an error. But for single-process functions I think it may be as simple as changing the meep::abort function to throw an exception, and adding an %except handler in SWIG to make sure this is caught as a Python exception.

That is, edit https://github.com/NanoComp/meep/blob/master/src/mympi.cpp#L121-L132 — if count_processors() == 1, then throw an exception rather than calling abort/exit.

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

Successfully merging a pull request may close this issue.

2 participants