flaport / fdtd

A 3D electromagnetic FDTD simulator written in Python with optional GPU support
https://fdtd.readthedocs.io
MIT License
454 stars 116 forks source link

Version on pypi doesn't have commit "don't use bd.float directly for type casting" and is erroring #60

Closed kyjohnso closed 1 year ago

kyjohnso commented 1 year ago

Version 0.2.6 on pypi doesn't have the commit 3cb63c27455e3f038dbd26b1394549a156 to "don't use bd.float directly for type casting". Without this commit, the initialization of a grid with any of the "torch" backends errors:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[8], line 1
----> 1 grid = fdtd.Grid(
      2     (2.5e-5, 1.5e-5, 1),
      3     grid_spacing=0.01 * WAVELENGTH,
      4     permittivity=1.0,
      5     permeability=1.0,
      6 )

File ~/projects/compem/venv/lib/python3.10/site-packages/fdtd/grid.py:143, in Grid.__init__(self, shape, grid_spacing, permittivity, permeability, courant_number)
    141 if bd.is_array(permittivity) and len(permittivity.shape) == 3:
    142     permittivity = permittivity[:, :, :, None]
--> 143 self.inverse_permittivity = bd.ones((self.Nx, self.Ny, self.Nz, 3)) / bd.float(
    144     permittivity
    145 )
    147 if bd.is_array(permeability) and len(permeability.shape) == 3:
    148     permeability = permeability[:, :, :, None]

TypeError: 'torch.dtype' object is not callable

Do you plan to push a new version to pypi?

python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] torch 1.13.1+cu117

flaport commented 1 year ago

Thanks for the reminder @kyjohnso . This should now be fixed by fdtd version 0.2.7.