NanoComp / meep

free finite-difference time-domain (FDTD) software for electromagnetic simulations
GNU General Public License v2.0
1.16k stars 596 forks source link

Dependence of calculation speed on the selected length unit #2714

Closed leSemaleon closed 7 months ago

leSemaleon commented 7 months ago

There is a simulation where the unit of length is 1 micron. Computation time is about 10 minutes. If I change the unit of length to 100 microns, the time increases to several hours. Of course, I proportionally reduce all lengths. I don't think this is working correctly

stevengj commented 7 months ago

You probably forgot to scale something dimensionful, e.g. you didn't scale the resolution or the time arguments correctly. Note also that if the unit of distance is "a", then the units of time are "c/a", so you need to also rescale times and/or frequencies.

leSemaleon commented 7 months ago

I use until_after_source=mp.stop_when_fields_decayed(50/unit, mp.Ey, pt, accuracityOfDecay), where unit is meep unit. I think this equation takes into account the change in time when the measurement of length changes

stevengj commented 7 months ago

Then probably you have a bug in your units somewhere else?

It's impossible to say more without seeing your code. Can you boil it down to a few-line example, e.g. which just runs a small simulation in vacuum?

leSemaleon commented 7 months ago

I actually didn't change the stop_when_fields_decayed field at first. That is, with a different unit of length, the field was checked too rarely, which is why the simulation was delayed. Now the simulation time does not depend on the unit of length