2024-02-14 12:33:40 +01:00
|
|
|
import tidy3d as td
|
|
|
|
import sympy as sp
|
|
|
|
import sympy.physics.units as spu
|
|
|
|
|
2024-03-10 11:56:37 +01:00
|
|
|
from .... import contracts as ct
|
2024-02-14 12:33:40 +01:00
|
|
|
from .... import sockets
|
|
|
|
from ... import base
|
|
|
|
|
2024-03-10 11:56:37 +01:00
|
|
|
class BoxStructureNode(base.MaxwellSimNode):
|
|
|
|
node_type = ct.NodeType.BoxStructure
|
2024-02-14 12:33:40 +01:00
|
|
|
bl_label = "Box Structure"
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Sockets
|
|
|
|
####################
|
|
|
|
input_sockets = {
|
2024-03-10 11:56:37 +01:00
|
|
|
"Medium": sockets.MaxwellMediumSocketDef(),
|
|
|
|
"Center": sockets.PhysicalPoint3DSocketDef(),
|
|
|
|
"Size": sockets.PhysicalSize3DSocketDef(),
|
2024-02-14 12:33:40 +01:00
|
|
|
}
|
|
|
|
output_sockets = {
|
2024-03-10 11:56:37 +01:00
|
|
|
"Structure": sockets.MaxwellStructureSocketDef(),
|
2024-02-14 12:33:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Output Socket Computation
|
|
|
|
####################
|
2024-03-10 11:56:37 +01:00
|
|
|
@base.computes_output_socket(
|
|
|
|
"Structure",
|
|
|
|
input_sockets={"Medium", "Center", "Size"},
|
|
|
|
)
|
|
|
|
def compute_simulation(self, input_sockets: dict) -> td.Box:
|
|
|
|
medium = input_sockets["Medium"]
|
|
|
|
_center = input_sockets["Center"]
|
|
|
|
_size = input_sockets["Size"]
|
2024-02-19 18:36:16 +01:00
|
|
|
|
|
|
|
center = tuple(spu.convert_to(_center, spu.um) / spu.um)
|
|
|
|
size = tuple(spu.convert_to(_size, spu.um) / spu.um)
|
2024-02-14 12:33:40 +01:00
|
|
|
|
|
|
|
return td.Structure(
|
|
|
|
geometry=td.Box(
|
|
|
|
center=center,
|
|
|
|
size=size,
|
|
|
|
),
|
|
|
|
medium=medium,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Registration
|
|
|
|
####################
|
|
|
|
BL_REGISTER = [
|
|
|
|
BoxStructureNode,
|
|
|
|
]
|
|
|
|
BL_NODES = {
|
2024-03-10 11:56:37 +01:00
|
|
|
ct.NodeType.BoxStructure: (
|
|
|
|
ct.NodeCategory.MAXWELLSIM_STRUCTURES_PRIMITIVES
|
2024-02-14 12:33:40 +01:00
|
|
|
)
|
|
|
|
}
|