How to define diagonal slices #2944
Unanswered
Olav-Schiess
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can you output a parameter along a diagonal slice (or any angled plane)?
When defining slices or volumes in meep it seems to always use center and size. Can these be used for diagonal slices?
Here's a code snippet of how I take the field for an xz slice which works nicely using the center and size:
sim.run( mp.at_every(dt, mp.in_volume(mp.Volume(center=mp.Vector3(0, 0, 0), size=mp.Vector3(sx, 0, substrate_thickness*3)),
mp.to_appended("xz_slice", mp.output_efield))), until=20)
For diagonal z slice I run different points in the diagonal manually which works but inefficiently as it creates files for each point.
diagonal_sample_points = [ mp.Vector3(x, y, z) for z in z_coords for x, y in zip(x_coords, y_coords)]
all_step_funcs = [] # Initialize an empty list to collect all the step functions
for idx, pt in enumerate(diagonal_sample_points):
# Append the step function for each point to the all_step_funcs list
all_step_funcs.append(mp.in_point(pt, mp.to_appended("point" + "_" + str(idx), mp.output_efield)))
sim.run(
mp.at_every(
dt,
mp.combine_step_funcs(*all_step_funcs), # Combine all the collected step functions
), until=1,
)
Beta Was this translation helpful? Give feedback.
All reactions