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

Field in position of source #43

Open
GenB31415 opened this issue Jan 3, 2022 · 3 comments
Open

Field in position of source #43

GenB31415 opened this issue Jan 3, 2022 · 3 comments

Comments

@GenB31415
Copy link

Hi @flaport, Happy New Year! At FDTD calculations I need to periodically change the power of a source (initially F_0) dependently on the local field amplitude E_0. So first I have to know the amplitude of field E_0 in current position of a source in 3D. Latter I will modify the power of this source periodically as F_{n+1} = f(E_n)*F_n with the interval dt. As I understand, to do that I have to periodically remove old source (n) from the grid and insert in this position new source (n+1). What is the optimal way to do all of that? Thank you in advance.

@flaport
Copy link
Owner

flaport commented Jan 5, 2022

hey @GenB31415 ,

It's probably best to write a custom source for this. The grid to which the source is attached is available as self.grid, and hence you have access to the field values at the current time step.

To write a custom source you just have to an update_E and an update_H method (look for example at sources.py).

For example, you could do something like this:

class MyPointSource(PointSource):
    def update_E(self):
        E_n = self.grid.E[self.x, self.y, self.z, 2]
        E_n[:, :, :] = my_func(E_n) * En

@GenB31415
Copy link
Author

Hi @flaport, please specify the formula of spatial shape of the fdtd.LineSource. In the docs it is only indicated “""Create a LineSource with a gaussian profile. Does it mean \exp(-(x-x0)^2-(y-y0)^2-(z-z0)^2) ? Is it possible to indicate a width of a gaussian? Thanks

@GenB31415
Copy link
Author

May be it is better to replace the word LineSource by PlaneSource in the description of PlaneSource ?

PlaneSource class

class PlaneSource:
"""A source along a plane in the FDTD grid"""

def __init__(...)
    """Create a **_LineSource_** with a gaussian profile

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

No branches or pull requests

2 participants