-
Notifications
You must be signed in to change notification settings - Fork 43
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
Added CustomSourceTime #994
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a few notes for discussion
I think Tyler's question about using |
7f7739f
to
0d1d1cd
Compare
0d1d1cd
to
49fa5ee
Compare
4dde2c3
to
00f56d2
Compare
00f56d2
to
d198b4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, let's wait to merge until @momchil-flex has a final look in conjunction with the backend tests, thanks @caseyflex !
d198b4b
to
f2c530d
Compare
I changed a minor thing -- allowing a dt of tolerance in covering the Simulation.tmesh, and just using the end values if needed in this case. |
Just occurred to me, eventually, it would probably be useful to provide a class method to generate this source time from data in the frequency domain as well. |
tidy3d/components/simulation.py
Outdated
continue | ||
times = dataset.values.coords["t"].values | ||
if ( | ||
min(times) >= self.tmesh[0] + CUSTOMSOURCETIME_TOL * self.dt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the intuition behind this choice? so the user can essentially start the time coordinates at dt
and end them at run_time - dt
and it should pass?
Yeah. I just found that without any tolerance on the ends, I would get
errors because of floating point issues, like being just under the actual
range. A dt on either side shouldn’t hurt.
…On Thu, Jul 27, 2023 at 7:02 PM Tyler Hughes ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In tidy3d/components/simulation.py
<#994 (comment)>:
> @@ -908,6 +913,34 @@ def _validate_tfsf_nonuniform_grid(self) -> None:
f"axis, '{'xyz'[source.injection_axis]}'."
)
+ def _validate_customsourcetime(self) -> None:
+ """Make sure custom source time is not undersampled.
+ Also, make sure that all simulation.tmesh values are covered."""
+ for source in self.sources:
+ if isinstance(source.source_time, CustomSourceTime):
+ dataset = source.source_time.source_time_dataset
+ if dataset is None:
+ continue
+ times = dataset.values.coords["t"].values
+ if (
+ min(times) >= self.tmesh[0] + CUSTOMSOURCETIME_TOL * self.dt
what is the intuition behind this choice? so the user can essentially
start the time coordinates at dt and end them at run_time - dt and it
should pass?
—
Reply to this email directly, view it on GitHub
<#994 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3KLECMLGNSG4QWZLDMF6LTXSKUNBANCNFSM6AAAAAA2GBD6QA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Could make it fp_eps I suppose, instead of dt
On Thu, Jul 27, 2023 at 7:04 PM Charles Wojcik ***@***.***>
wrote:
… Yeah. I just found that without any tolerance on the ends, I would get
errors because of floating point issues, like being just under the actual
range. A dt on either side shouldn’t hurt.
On Thu, Jul 27, 2023 at 7:02 PM Tyler Hughes ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In tidy3d/components/simulation.py
> <#994 (comment)>:
>
> > @@ -908,6 +913,34 @@ def _validate_tfsf_nonuniform_grid(self) -> None:
> f"axis, '{'xyz'[source.injection_axis]}'."
> )
>
> + def _validate_customsourcetime(self) -> None:
> + """Make sure custom source time is not undersampled.
> + Also, make sure that all simulation.tmesh values are covered."""
> + for source in self.sources:
> + if isinstance(source.source_time, CustomSourceTime):
> + dataset = source.source_time.source_time_dataset
> + if dataset is None:
> + continue
> + times = dataset.values.coords["t"].values
> + if (
> + min(times) >= self.tmesh[0] + CUSTOMSOURCETIME_TOL * self.dt
>
> what is the intuition behind this choice? so the user can essentially
> start the time coordinates at dt and end them at run_time - dt and it
> should pass?
>
> —
> Reply to this email directly, view it on GitHub
> <#994 (review)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/A3KLECMLGNSG4QWZLDMF6LTXSKUNBANCNFSM6AAAAAA2GBD6QA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
But the tmesh already runs to run_time + dt, and it’s most natural to have
the source go only to run_time
On Thu, Jul 27, 2023 at 7:05 PM Charles Wojcik ***@***.***>
wrote:
… Could make it fp_eps I suppose, instead of dt
On Thu, Jul 27, 2023 at 7:04 PM Charles Wojcik ***@***.***>
wrote:
> Yeah. I just found that without any tolerance on the ends, I would get
> errors because of floating point issues, like being just under the actual
> range. A dt on either side shouldn’t hurt.
>
> On Thu, Jul 27, 2023 at 7:02 PM Tyler Hughes ***@***.***>
> wrote:
>
>> ***@***.**** commented on this pull request.
>> ------------------------------
>>
>> In tidy3d/components/simulation.py
>> <#994 (comment)>:
>>
>> > @@ -908,6 +913,34 @@ def _validate_tfsf_nonuniform_grid(self) -> None:
>> f"axis, '{'xyz'[source.injection_axis]}'."
>> )
>>
>> + def _validate_customsourcetime(self) -> None:
>> + """Make sure custom source time is not undersampled.
>> + Also, make sure that all simulation.tmesh values are covered."""
>> + for source in self.sources:
>> + if isinstance(source.source_time, CustomSourceTime):
>> + dataset = source.source_time.source_time_dataset
>> + if dataset is None:
>> + continue
>> + times = dataset.values.coords["t"].values
>> + if (
>> + min(times) >= self.tmesh[0] + CUSTOMSOURCETIME_TOL * self.dt
>>
>> what is the intuition behind this choice? so the user can essentially
>> start the time coordinates at dt and end them at run_time - dt and it
>> should pass?
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <#994 (review)>,
>> or unsubscribe
>> <https://github.com/notifications/unsubscribe-auth/A3KLECMLGNSG4QWZLDMF6LTXSKUNBANCNFSM6AAAAAA2GBD6QA>
>> .
>> You are receiving this because you were mentioned.Message ID:
>> ***@***.***>
>>
>
|
Could also have no tolerance at 0, and a dt of tolerance at run_time.
On Thu, Jul 27, 2023 at 7:06 PM Charles Wojcik ***@***.***>
wrote:
… But the tmesh already runs to run_time + dt, and it’s most natural to have
the source go only to run_time
On Thu, Jul 27, 2023 at 7:05 PM Charles Wojcik ***@***.***>
wrote:
> Could make it fp_eps I suppose, instead of dt
>
> On Thu, Jul 27, 2023 at 7:04 PM Charles Wojcik ***@***.***>
> wrote:
>
>> Yeah. I just found that without any tolerance on the ends, I would get
>> errors because of floating point issues, like being just under the actual
>> range. A dt on either side shouldn’t hurt.
>>
>> On Thu, Jul 27, 2023 at 7:02 PM Tyler Hughes ***@***.***>
>> wrote:
>>
>>> ***@***.**** commented on this pull request.
>>> ------------------------------
>>>
>>> In tidy3d/components/simulation.py
>>> <#994 (comment)>
>>> :
>>>
>>> > @@ -908,6 +913,34 @@ def _validate_tfsf_nonuniform_grid(self) -> None:
>>> f"axis, '{'xyz'[source.injection_axis]}'."
>>> )
>>>
>>> + def _validate_customsourcetime(self) -> None:
>>> + """Make sure custom source time is not undersampled.
>>> + Also, make sure that all simulation.tmesh values are covered."""
>>> + for source in self.sources:
>>> + if isinstance(source.source_time, CustomSourceTime):
>>> + dataset = source.source_time.source_time_dataset
>>> + if dataset is None:
>>> + continue
>>> + times = dataset.values.coords["t"].values
>>> + if (
>>> + min(times) >= self.tmesh[0] + CUSTOMSOURCETIME_TOL * self.dt
>>>
>>> what is the intuition behind this choice? so the user can essentially
>>> start the time coordinates at dt and end them at run_time - dt and it
>>> should pass?
>>>
>>> —
>>> Reply to this email directly, view it on GitHub
>>> <#994 (review)>,
>>> or unsubscribe
>>> <https://github.com/notifications/unsubscribe-auth/A3KLECMLGNSG4QWZLDMF6LTXSKUNBANCNFSM6AAAAAA2GBD6QA>
>>> .
>>> You are receiving this because you were mentioned.Message ID:
>>> ***@***.***>
>>>
>>
|
f2c530d
to
10b94d8
Compare
Alright momchil pointed me to the backend code and the handling for out of bounds and that looks fine. I thought for a second that we just evaluated the |
10b94d8
to
3934787
Compare
Features: