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

Relax stability condition for simulations smaller than 3D #1678

Open
momchil-flex opened this issue May 3, 2024 · 4 comments
Open

Relax stability condition for simulations smaller than 3D #1678

momchil-flex opened this issue May 3, 2024 · 4 comments
Assignees

Comments

@momchil-flex
Copy link
Collaborator

I believe the time step stability condition here can be relaxed to only sum over dl-s that are not along 0-size dims. In other words, e.g. for 2D sims only the dl along the two physical simulation dimensions should count. We just need to make sure that this is indeed correct (theoretically), and that all tests pass. Maybe also just in case test with a 2D simulation with a long run time and periodic boundary conditions such that fields just keep going around, and we make sure there's no divergence.

@QimingFlex
Copy link

Hi @momchil-flex , I tested the step size recommended by the 2D CFL condition for a 2D cavity. The solution is stable and does not diverge after long simulation (1 million steps). Theoretically, this seems correct as well, since the update equations are identical to those used in the 2D update equations. For a uniform mesh, this would allow for a sqrt(3/2) larger time step than the current step size. I'm trying to determine where Tidy3D classifies a simulation as '2D.' So far, I have noticed that source injection fails when the simulation size is 0 along 0-size dims. It only works when a small but non-zero size is specified.

@momchil-flex
Copy link
Collaborator Author

Yeah, we don't classify a simulation as 2D in any other way than by defining the simulation size as 0. Sources and monitors that are planar still need to be 2D objects themselves. This is because we use the 0-sized dim of these objects to determine a normal axis. So yeah typically a source in a 2D sim will still be a 2D plane with a non-zero size along the simulation 0-dim. Does that make sense?

@QimingFlex
Copy link

I understand that the source and monitor should take non-zero values along a 0-sized dimension, but the simulation size should be exactly zero along this dimension. However, if I set the simulation size to zero, it fails to inject fields, resulting in zero values everywhere. Currently, I address this by assigning a very small value along the 0-sized dimension, which triggers the 2D simulation. The cell size along this dimension is not restricted by the small value given. This appears to be a separate issue. On another note, the relaxed stability condition works well. How should I proceed with preparing the tests?

@momchil-flex
Copy link
Collaborator Author

I understand that the source and monitor should take non-zero values along a 0-sized dimension, but the simulation size should be exactly zero along this dimension. However, if I set the simulation size to zero, it fails to inject fields, resulting in zero values everywhere.

What setup are you talking about exactly? We have many 2D simulations where the simulation size is 0 and everything is fine.

Currently, I address this by assigning a very small value along the 0-sized dimension, which triggers the 2D simulation.

Actually I think we have some checks in a number of places if the simulation size is strictly zero. We treat this slightly differently than a non-zero-size but single-pixel simulation and the preferred way is probably to have size 0 if the simulation is 2D. Also, what do you mean "triggers the 2D simulation"? Just that there is one pixel along that direction?

The cell size along this dimension is not restricted by the small value given. This appears to be a separate issue.

I think this may be something we've implemented so people don't get an incredibly small time step if they happen to put a very small simulation size?

On another note, the relaxed stability condition works well. How should I proceed with preparing the tests?

We don't have explicit tests about stability and I think it's fine not to include such tests if you tested with a long simulation. We have many 2D examples in both our tests and in our notebooks and if something is unstable we'd probably catch it.

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