NanoComp / meep

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

geometry rotation #1668

Open ReDoDx09 opened 3 years ago

ReDoDx09 commented 3 years ago

hello all, is it possible to rotate an heterogeneous object on meep ? i have this structure which I created using meep (below my script) and I want to rotate by angle theta

phantom

script : import meep as mp import math import cmath from matplotlib import pyplot as plt

simulation_size = 20 AXIAL=20.0 LATERALSIZE=30.0 dpml = 0.5#3 sxx = LATERALSIZE sxy = AXIAL#simulation_size + dpml

sxz = simulation_size + dpml

WAVELENGTH=13 resolution = WAVELENGTH MEDIUM_RI=1.333 CYTOPLASM_RI=1.365 CYTOPLASM_A=8.5 CYTOPLASM_B=7.0

NUCLEUS_RI=1.360 NUCLEUS_A=4.5 NUCLEUS_B=3.5 NUCLEUS_PHI=0.5 NUCLEUS_X=2.0 NUCLEUS_Y=1.0

NUCLEOLUS_RI=1.387 NUCLEOLUS_A=1.0 NUCLEOLUS_B=1.0 NUCLEOLUS_PHI=0.0 NUCLEOLUS_X=2.0 NUCLEOLUS_Y=2.0

cell = mp.Vector3(sxx, sxy, 0) pml_layers = [mp.PML(dpml)]

cytoplasm_material = mp.Medium(index=CYTOPLASM_RI) nucleolus_material=mp.Medium(index=NUCLEOLUS_RI) nucleus_material=mp.Medium(index=NUCLEUS_RI)

cytoplasm_geometry=mp.Ellipsoid(center=mp.Vector3(0,0),size=mp.Vector3(8,7),material=cytoplasm_material)

cytoplasm_geometry=mp.Ellipsoid(center=mp.Vector3(0,0), size=mp.Vector3(8.5,7,1), material=cytoplasm_material)

cytoplasm_geometry=mp.Sphere(radius=5,center=(0,0),material=cytoplasm_material)

nucleolus_geometry=mp.Sphere(radius=1,center=(1,0),material=nucleolus_material) nucleus_geometry=mp.Ellipsoid(center=mp.Vector3(1,0),size=mp.Vector3(4.5,3.5,1),material=nucleus_material) geometry = [cytoplasm_geometry,nucleus_geometry,nucleolus_geometry]

sim = mp.Simulation(cell_size=cell, boundary_layers=pml_layers, geometry=geometry,

sources=sources,

                geometry_center=(0,0),
                default_material=mp.Medium(index=MEDIUM_RI),
                resolution=resolution)

plt.figure(dpi=100) sim.plot2D() plt.show()

stevengj commented 3 years ago

I don't think we have any built-in function to rotate a collection of objects. It would be pretty easy to write your own function, though.

ReDoDx09 commented 3 years ago

@stevengj thank you for you answer i don't know from where should I start because i want to rotate this object in range of angles... can you help me ?

stevengj commented 3 years ago

Write a function to rotate an object — there are built in geometry routines to rotate vectors, so rotating the objects can be built on that. Once you have that, just map the function over an array of objects.

scigg commented 2 years ago

@stevengj Would you describe mapping the function over an array of objects a bit more? Can we apply this mapping to a collection of objects in the form of geometry list, geometry=[object1, object2, object3]?