NanoComp / meep

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

Fill factor in meep #2821

Closed zebihcetin closed 2 months ago

zebihcetin commented 2 months ago

Hello everyone, I would like to thank you for your great work.

Is there a way or a function in meep to calculate the total volume occupied by complicated geometric objects within the simulation region?.

zebihcetin commented 2 months ago

Hello everyone, I would like to thank you for your great work.

Is there a way or a function in meep to calculate the total volume occupied by complicated geometric objects within the simulation region?.

In mpb when calling output_epsilon() function on ModeSolver it gives the following terminal output at the end of the calculation:
epsilon: 1-3, mean 1.10108, harm. mean 1.04491, 11.3384% > 1, 5.05414% "fill"

what are those two % values represent. The last one seems to be the filling ratio that i need but i am not sure

stevengj commented 2 months ago

You can get epsilon as a numpy array and do whatever calculations you want. You can also use the field-integration routines to integrate a function of ε over any desired volume, e.g. to compute a fill fraction.

The numbers you quoted are computed here. The first percentage is the percentage of grid points in the unit cell that have ε > 1.0001, but this includes grid points that are only slightly larger due to subpixel averaging (essentially, every dielectric object is surrounded by a "halo" 1-pixel thick of intermediate ε values due to subpixel averaging) … it converges to the fill factor of ε > 1 in the limit of infinite resolution. The second percentage is 100.0 * (eps_mean-eps_low) / (eps_high-eps_low), which uses the mean ε over all grid points … this is also the fill factor f in the limit of infinite resolution for a 2-material system (where the mean is mean ε = fε₁ + (1-f)ε₂ so that the fill factor of ε₁ is therefore f = (mean ε - ε₂) / (ε₁ - ε₂)).

So, you can use either number if your resolution is high enough; if they differ significantly then either your resolution is too low or you have a system with more than 3 materials.