anstmichaels / emopt

A suite of tools for optimizing the shape and topology of electromagnetic structures.
BSD 3-Clause "New" or "Revised" License
97 stars 41 forks source link

ModeFullVector: PETSc error: both n and N cannot be PETSC_DECIDE #9

Closed sbuchbinder closed 4 years ago

sbuchbinder commented 4 years ago

I am trying to calculate the 2d cross section mode of a waveguide (built using StructuredMaterial3D).

num_modes = 1

# Calculate the input mode
domain_in = emopt.misc.DomainCoordinates(xmin=x0, xmax=x0,
                                         ymin=w_pml, ymax=Y - w_pml,
                                         zmin=w_pml, zmax=Z - w_pml,
                                         dx=dx, dy=dy, dz=dz)

mode_in = emopt.modes.ModeFullVector(wavelength=wavelength,
                                     eps=eps,
                                     mu=mu,
                                     domain=domain_in,
                                     n0=np.sqrt(eps_Si),
                                     neigs=num_modes
                                     )

When I try to run, I get an error: Arguments are incompatible Both n and N cannot be PETSC_DECIDE

Traceback (most recent call last): File ".../my_file.py", line 105, in neigs=num_modes File ".../emopt/modes.py", line 1209, in init self._A.setUp() File "PETSc/Mat.pyx", line 570, in petsc4py.PETSc.Mat.setUp

Following https://lists.mcs.anl.gov/pipermail/petsc-users/2015-January/023985.html, I tried changing line 1207 of modes.py to: self._A.setSizes([(Nfields*self._M*self._N, PETSc.DETERMINE), (Nfields*self._M*self._N, PETSc.DETERMINE)])

This gave an out of memory error (amusingly, Memory requested 18446744073709520896). Though my structure is significantly smaller than the one used in the examples/waveguide_modes/wg_modes_3D.py.

Any ideas?

anstmichaels commented 4 years ago

Odd, I havent seen this one before. Do you have an example file which produces the problem so that I can take a look? Does the wg_modes_3D.py example work on your machine? Also, what version of PETSc do you have installed?

sbuchbinder commented 4 years ago

I was able to figure this one out earlier today.

The key is to not have w_pml be a list (as returned from the sim object).