flexcompute / tidy3d

Fast electromagnetic solver (FDTD) at scale.
https://docs.flexcompute.com/projects/tidy3d/en/latest/
GNU Lesser General Public License v2.1
194 stars 44 forks source link

Q factor extract and filed plot issue #1505

Closed chenyudong92 closed 9 months ago

chenyudong92 commented 9 months ago

Describe the bug When I try to use my structure to extract Q factor. I find the extracted Q factor have negative value. And when I try to plot the filed distribution, I saw the error: ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (0.13127594810379228).

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Want to extract the correct Q factor and filed distribution

Screenshots nagtive Q factor plot issue

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

caseyflex commented 9 months ago

Describe the bug When I try to use my structure to extract Q factor. I find the extracted Q factor have negative value. And when I try to plot the filed distribution, I saw the error: ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (0.13127594810379228).

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Want to extract the correct Q factor and filed distribution

Screenshots nagtive Q factor plot issue

Desktop (please complete the following information):

  • OS: Windows
  • Browser: chrome
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

Hi,

Negative Q generally means that the run_time was not long enough to resolve the Q. You might also need to adjust the shutoff. Also, your frequency range is fairly broad -- the ResonanceFinder is finding many resonances each with large error, which may be spurious. I'd recommend checking the spectrum manually as in cell [11] of this notebook: https://docs.flexcompute.com/projects/tidy3d/en/latest/notebooks/ResonanceFinder.html Make sure you can clearly see the desired resonances. Also, make sure you start your monitors after the source has decayed.

I'm not sure exactly what you were plotting -- could you provide more information about the setup and commands you tried? It looks like you were evaluating at some position (say x=0) which was outside of the interpolation range for the xr.DataArray (which is defined by the monitor setup). Depending on what you want to do, you could try adding the kwarg method="nearest" to the plot call.

Thanks, Casey

chenyudong92 commented 9 months ago

Thanks for your suggestion. I fixed the plot issue. But I am not sure how to adjust the shutoff. Any tutorial of it? Also, for the running time, are there any suggestions?

Sincerely, Yudong Chen M.S. of Electrical Engineering at SMU Ph.D. Student of Electrical Engineering at UTA Office at 2nd floor at Nano Fab in UTA


From: caseyflex @.> Sent: Wednesday, February 28, 2024 4:57 To: flexcompute/tidy3d @.> Cc: Chen, Yudong @.>; Author @.> Subject: Re: [flexcompute/tidy3d] Q factor extract and filed plot issue (Issue #1505)

[External]

Describe the bug When I try to use my structure to extract Q factor. I find the extracted Q factor have negative value. And when I try to plot the filed distribution, I saw the error: ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (0.13127594810379228).

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Want to extract the correct Q factor and filed distribution

Screenshots [nagtive Q factor] https://private-user-images.githubusercontent.com/57641431/308282854-371aebff-9736-4f84-ad22-c279cc7017a1.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkxMTcxOTUsIm5iZiI6MTcwOTExNjg5NSwicGF0aCI6Ii81NzY0MTQzMS8zMDgyODI4NTQtMzcxYWViZmYtOTczNi00Zjg0LWFkMjItYzI3OWNjNzAxN2ExLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjI4VDEwNDEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViZTRjZmZlMWQ1ZjNiYmY5ODFkYzkyMTRhZTIwYzMxY2YwNzJhMzRkNDE3YmZhOThiYzdlY2E1MTZiOTkwY2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.feppl8nBaB4kMs0F3dSrh7RR584iw625D6kIJgI8p14 [plot issue] https://private-user-images.githubusercontent.com/57641431/308282876-3aa4352d-a9f7-4641-86aa-7dcbfd9e3974.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkxMTcxOTUsIm5iZiI6MTcwOTExNjg5NSwicGF0aCI6Ii81NzY0MTQzMS8zMDgyODI4NzYtM2FhNDM1MmQtYTlmNy00NjQxLTg2YWEtN2RjYmZkOWUzOTc0LkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjI4VDEwNDEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZDU4ZjkwNmY4YTg1NzVjNzJkMzRmMTEyMTE3MTNjZGRhZDJhMzgxZTM5OTM0YmM5MzA1MzdmNGM1MzE1Y2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pgZBLI5ndRTYQZ1nBLhGfDm8DZc_jwhq4lydtP2HK1w

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

Hi,

Negative Q generally means that the run_time was not long enough to resolve the Q. You might also need to adjust the shutoff. Also, your frequency range is fairly broad -- the ResonanceFinder is finding many resonances each with large error, which may be spurious. I'd recommend checking the spectrum manually as in cell [11] of this notebook: https://docs.flexcompute.com/projects/tidy3d/en/latest/notebooks/ResonanceFinder.html Make sure you can clearly see the desired resonances. Also, make sure you start your monitors after the source has decayed.

I'm not sure exactly what you were plotting -- could you provide more information about the setup and commands you tried? It looks like you were evaluating at some position (say x=0) which was outside of the interpolation range for the xr.DataArray (which is defined by the monitor setup).

Thanks, Casey

— Reply to this email directly, view it on GitHubhttps://github.com/flexcompute/tidy3d/issues/1505#issuecomment-1968732342, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANXYTV4GXIG2RXX5JBJ7ZKDYV4ERFAVCNFSM6AAAAABD4SDHMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYG4ZTEMZUGI. You are receiving this because you authored the thread.Message ID: @.***>

caseyflex commented 9 months ago

Thanks for your suggestion. I fixed the plot issue. But I am not sure how to adjust the shutoff. Any tutorial of it? Also, for the running time, are there any suggestions? Sincerely, Yudong Chen M.S. of Electrical Engineering at SMU Ph.D. Student of Electrical Engineering at UTA Office at 2nd floor at Nano Fab in UTA ____ From: caseyflex @.> Sent: Wednesday, February 28, 2024 4:57 To: flexcompute/tidy3d @.> Cc: Chen, Yudong @.>; Author @.> Subject: Re: [flexcompute/tidy3d] Q factor extract and filed plot issue (Issue #1505) [External] Describe the bug When I try to use my structure to extract Q factor. I find the extracted Q factor have negative value. And when I try to plot the filed distribution, I saw the error: ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (0.13127594810379228). To Reproduce Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error Expected behavior Want to extract the correct Q factor and filed distribution Screenshots [nagtive Q factor] https://private-user-images.githubusercontent.com/57641431/308282854-371aebff-9736-4f84-ad22-c279cc7017a1.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkxMTcxOTUsIm5iZiI6MTcwOTExNjg5NSwicGF0aCI6Ii81NzY0MTQzMS8zMDgyODI4NTQtMzcxYWViZmYtOTczNi00Zjg0LWFkMjItYzI3OWNjNzAxN2ExLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjI4VDEwNDEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViZTRjZmZlMWQ1ZjNiYmY5ODFkYzkyMTRhZTIwYzMxY2YwNzJhMzRkNDE3YmZhOThiYzdlY2E1MTZiOTkwY2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.feppl8nBaB4kMs0F3dSrh7RR584iw625D6kIJgI8p14 [plot issue] https://private-user-images.githubusercontent.com/57641431/308282876-3aa4352d-a9f7-4641-86aa-7dcbfd9e3974.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkxMTcxOTUsIm5iZiI6MTcwOTExNjg5NSwicGF0aCI6Ii81NzY0MTQzMS8zMDgyODI4NzYtM2FhNDM1MmQtYTlmNy00NjQxLTg2YWEtN2RjYmZkOWUzOTc0LkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjI4VDEwNDEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZDU4ZjkwNmY4YTg1NzVjNzJkMzRmMTEyMTE3MTNjZGRhZDJhMzgxZTM5OTM0YmM5MzA1MzdmNGM1MzE1Y2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pgZBLI5ndRTYQZ1nBLhGfDm8DZc_jwhq4lydtP2HK1w Desktop (please complete the following information): OS: Windows Browser: chrome Version [e.g. 22] Smartphone (please complete the following information): Device: [e.g. iPhone6] OS: [e.g. iOS8.1] Browser [e.g. stock browser, safari] * Version [e.g. 22] Additional context Add any other context about the problem here. Hi, Negative Q generally means that the run_time was not long enough to resolve the Q. You might also need to adjust the shutoff. Also, your frequency range is fairly broad -- the ResonanceFinder is finding many resonances each with large error, which may be spurious. I'd recommend checking the spectrum manually as in cell [11] of this notebook: https://docs.flexcompute.com/projects/tidy3d/en/latest/notebooks/ResonanceFinder.html Make sure you can clearly see the desired resonances. Also, make sure you start your monitors after the source has decayed. I'm not sure exactly what you were plotting -- could you provide more information about the setup and commands you tried? It looks like you were evaluating at some position (say x=0) which was outside of the interpolation range for the xr.DataArray (which is defined by the monitor setup). Thanks, Casey — Reply to this email directly, view it on GitHub<#1505 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANXYTV4GXIG2RXX5JBJ7ZKDYV4ERFAVCNFSM6AAAAABD4SDHMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYG4ZTEMZUGI. You are receiving this because you authored the thread.Message ID: @.***>

Actually, in your situation, because all of the resonances seem spurious (not just one with negative Q), I would start by plotting the FieldTimeMonitor data as in cell [9] of the ResonanceFinder notebook I linked earlier. You should verify that the source has decayed. If you have an idea of the lifetime of the resonance, you can confirm that here too. You can also add FieldMonitor over a range of frequencies to look at the frequency-domain response -- you'll ideally see a well-defined peak corresponding to each resonance. Then this can guide the frequency window you use for the ResonanceFinder.

In the FieldTimeMonitor data, if you observe that the source has decayed but the fields are not decaying over the simulation time scale, then you could consider increasing the run_time. It will need to be some fraction (1/10 or 1/100) of the resonance lifetime -- too small and you won't be able to resolve its Q, too large and the simulation may be expensive. Together with this, you may find that the default shutoff factor 1e-5 is too large. Here's some general information on the shutoff: https://docs.flexcompute.com/projects/tidy3d/en/latest/faq/_faqs/how-can-i-optimize-the-simulation-cost.html#shutoff

caseyflex commented 9 months ago

Thanks for your suggestion. I fixed the plot issue. But I am not sure how to adjust the shutoff. Any tutorial of it? Also, for the running time, are there any suggestions? Sincerely, Yudong Chen M.S. of Electrical Engineering at SMU Ph.D. Student of Electrical Engineering at UTA Office at 2nd floor at Nano Fab in UTA ____ From: caseyflex @.> Sent: Wednesday, February 28, 2024 4:57 To: flexcompute/tidy3d @.> Cc: Chen, Yudong @.>; Author @.> Subject: Re: [flexcompute/tidy3d] Q factor extract and filed plot issue (Issue #1505) [External] Describe the bug When I try to use my structure to extract Q factor. I find the extracted Q factor have negative value. And when I try to plot the filed distribution, I saw the error: ValueError: A value (0.0) in x_new is below the interpolation range's minimum value (0.13127594810379228). To Reproduce Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error Expected behavior Want to extract the correct Q factor and filed distribution Screenshots [nagtive Q factor] https://private-user-images.githubusercontent.com/57641431/308282854-371aebff-9736-4f84-ad22-c279cc7017a1.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkxMTcxOTUsIm5iZiI6MTcwOTExNjg5NSwicGF0aCI6Ii81NzY0MTQzMS8zMDgyODI4NTQtMzcxYWViZmYtOTczNi00Zjg0LWFkMjItYzI3OWNjNzAxN2ExLkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjI4VDEwNDEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViZTRjZmZlMWQ1ZjNiYmY5ODFkYzkyMTRhZTIwYzMxY2YwNzJhMzRkNDE3YmZhOThiYzdlY2E1MTZiOTkwY2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.feppl8nBaB4kMs0F3dSrh7RR584iw625D6kIJgI8p14 [plot issue] https://private-user-images.githubusercontent.com/57641431/308282876-3aa4352d-a9f7-4641-86aa-7dcbfd9e3974.JPG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkxMTcxOTUsIm5iZiI6MTcwOTExNjg5NSwicGF0aCI6Ii81NzY0MTQzMS8zMDgyODI4NzYtM2FhNDM1MmQtYTlmNy00NjQxLTg2YWEtN2RjYmZkOWUzOTc0LkpQRz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAyMjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMjI4VDEwNDEzNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZDU4ZjkwNmY4YTg1NzVjNzJkMzRmMTEyMTE3MTNjZGRhZDJhMzgxZTM5OTM0YmM5MzA1MzdmNGM1MzE1Y2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pgZBLI5ndRTYQZ1nBLhGfDm8DZc_jwhq4lydtP2HK1w Desktop (please complete the following information): OS: Windows Browser: chrome Version [e.g. 22] Smartphone (please complete the following information): Device: [e.g. iPhone6] OS: [e.g. iOS8.1] Browser [e.g. stock browser, safari] * Version [e.g. 22] Additional context Add any other context about the problem here. Hi, Negative Q generally means that the run_time was not long enough to resolve the Q. You might also need to adjust the shutoff. Also, your frequency range is fairly broad -- the ResonanceFinder is finding many resonances each with large error, which may be spurious. I'd recommend checking the spectrum manually as in cell [11] of this notebook: https://docs.flexcompute.com/projects/tidy3d/en/latest/notebooks/ResonanceFinder.html Make sure you can clearly see the desired resonances. Also, make sure you start your monitors after the source has decayed. I'm not sure exactly what you were plotting -- could you provide more information about the setup and commands you tried? It looks like you were evaluating at some position (say x=0) which was outside of the interpolation range for the xr.DataArray (which is defined by the monitor setup). Thanks, Casey — Reply to this email directly, view it on GitHub<#1505 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANXYTV4GXIG2RXX5JBJ7ZKDYV4ERFAVCNFSM6AAAAABD4SDHMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRYG4ZTEMZUGI. You are receiving this because you authored the thread.Message ID: @.***>

You can also check out this notebook: https://docs.flexcompute.com/projects/tidy3d/en/latest/notebooks/Bandstructure.html It walks through some of these steps.

momchil-flex commented 9 months ago

I think we can close this @chenyudong92 - have you found all you need to understand the issue and how to use the ResonanceFinder?

chenyudong92 commented 9 months ago

yes, thanks

Sincerely, Yudong Chen M.S. of Electrical Engineering at SMU Ph.D. Student of Electrical Engineering at UTA Office at 2nd floor of NanoFab at UTA


发件人: momchil-flex @.> 发送时间: Thursday, February 29, 2024 6:33:10 PM 收件人: flexcompute/tidy3d @.> 抄送: Chen, Yudong @.>; Mention @.> 主题: Re: [flexcompute/tidy3d] Q factor extract and filed plot issue (Issue #1505)

[External]

I think we can close this @chenyudong92https://github.com/chenyudong92 - have you found all you need to understand the issue and how to use the ResonanceFinder?

― Reply to this email directly, view it on GitHubhttps://github.com/flexcompute/tidy3d/issues/1505#issuecomment-1972217381, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANXYTV4P2PC4AQW4UKOWQD3YV7EENAVCNFSM6AAAAABD4SDHMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSGIYTOMZYGE. You are receiving this because you were mentioned.Message ID: @.***>