kch3782 / torcwa

GPU-accelerated RCWA with automatic differentiation
Other
103 stars 21 forks source link

field_xyz ? #4

Closed zhixwang closed 2 years ago

zhixwang commented 2 years ago

Hi, I noticed that the program supports to extract field_xy, field_yz and field_xz.

Is it possible to extract field_xyz, so that I can do more complicated computations afterwards?

Thanks!

zhixwang commented 2 years ago

I mean, of course, I can write a for-loop and extract the field_xy along a series of z_prop iteratively. However, this will not be sufficiently vectorized and the speed will be limited.

Is it possible to input something like (x_axis, y_axis, z_axis = [z_prop]) such that we can directly read [Ex, Ey, Ez] as 3D-Tensors?

kch3782 commented 2 years ago

First, vectorize is theoretically possible. However, in the initial development, we tried fully vectorized operation, but when operating with the eigenmode of the internal layer and the phase of the vectorized z-axis, it requires huge memory size. (rcwa.py line968 - 988) We have not yet found a memory-efficient operation method, so we have not added a function to extract the 3D field.

zhixwang commented 2 years ago

Thanks for the reply. I can understand that memory becomes a bottleneck for GPU computation. Perhaps an option would be to implement a vectorized 3D function, and in the worst case people can at least use it on CPU?

Sometimes users also use CPU to run PyTorch.

kch3782 commented 2 years ago

We will consider 3D vectorized function when updating in the future. However, it may take a little longer to update due to verification. (Comparison with other electromagnetic simulations, etc.)

Thanks for the suggestion.

zhixwang commented 2 years ago

Thank you for taking care!