feat: Registered all nodes.

Also added several features including dynamic sockets
in nodes, abstracted units for sockets, and more.
Sofus Albert Høgsbro Rose 2024-02-19 14:28:35 +01:00
parent 9988cde7c7
commit 14891cd7cc
203 changed files with 2775 additions and 435 deletions

View File

@ -9,28 +9,25 @@ Now that we can do all the cool things ex. presets and such, it's time to think
- Inputs
- Scene
- Time
- Object Info
- Unit System
- Parameter: Sympy variables.
- Parameters: Sympy variables.
- *type* Parameter
- Constant: Typed numbers.
- Constants: Typed numbers.
- Scientific Constant
- *type* Constant
- Array
- From File: Concatenate two arrays.
- *type* Array Union
- Element: Create a 1-element array, with a typed value.
- *type* Array Element
- Lists
- *type* List Element
- File Data: Data from a file.
- *type* File Data
- Outputs
- Viewer
- Viewers
- Value Viewer: Live-monitoring.
- Console Viewer: w/Button to Print Types
- Exporter
- JSON File Export: Compatible with any socket implementing `.as_json()`.
- Plot
- Exporters
- JSON File Exporter: Compatible with any socket implementing `.as_json()`.
- Plotters
- *various kinds of plotting? To Blender datablocks primarily, maybe*.
- Sources
@ -62,17 +59,16 @@ Now that we can do all the cool things ex. presets and such, it's time to think
- Library Medium
- **NOTE**: Should provide an EnumProperty of materials with its own categorizations. It should provide another EnumProperty to choose the experiment. It should also be filterable by wavelength range, maybe also model info. Finally, a reference should be generated on use as text.
- Linear Mediums
- PEC Medium
- Isotropic Medium
- Anisotropic Medium
- PEC Medium
- Isotropic Medium
- Anisotropic Medium
- 3-Sellmeier Medium
- Sellmeier Medium
- Pole-Residue Medium
- Drude Medium
- Drude-Lorentz Medium
- Debye Medium
- 3-Sellmeier Medium
- Sellmeier Medium
- Pole-Residue Medium
- Drude Medium
- Drude-Lorentz Medium
- Debye Medium
- Non-Linearities
- Add Non-Linearity
@ -124,15 +120,14 @@ Now that we can do all the cool things ex. presets and such, it's time to think
- Simulations
- FDTD Sim
- Sim Grid
- Sim Grid Axis
- Automatic Sim Grid Axis
- Manual Sim Grid Axis
- Uniform Sim Grid Axis
- Array Sim Grid Axis
- Grid Discretizations
- Sim Grid
- Grid Axis
- Automatic Grid Axis
- Manual Grid Axis
- Uniform Grid Axis
- Data-Driven Grid Axis
- FDTD Sim
@ -140,21 +135,23 @@ Now that we can do all the cool things ex. presets and such, it's time to think
- Math: Contains a dropdown for operation.
- *type* Math: **Be careful about units :)**
- Operations
- Array Operation
- List Operation
## Sockets
- basic
- Any
- FilePath
- Text
- math
- number
- IntegerNumber
- RationalNumber
- RealNumber
- ComplexNumber
- RealNumberField
- ComplexNumberField
- vector
- Real2DVector
- Complex2DVector
- Real2DVectorField
@ -185,7 +182,6 @@ Now that we can do all the cool things ex. presets and such, it's time to think
- PhysicalPolarization
- PhysicalFrequency
- PhysicalSpectralDomain
- PhysicalSpectralDistribution
- blender
- BlenderObject

View File

@ -72,10 +72,10 @@ def mk_node_categories(
# - Blender Registration
####################
BL_NODE_CATEGORIES = mk_node_categories(
contracts.NodeCategory.get_tree()["MAXWELL"]["SIM"],
syllable_prefix = ["MAXWELL", "SIM"],
contracts.NodeCategory.get_tree()["MAXWELLSIM"],
syllable_prefix = ["MAXWELLSIM"],
)
## TODO: refractor, this has a big code smell
## TODO: refactor, this has a big code smell
BL_REGISTER = [
*DYNAMIC_SUBMENU_REGISTRATIONS
] ## Must be run after, right now.

View File

@ -3,12 +3,16 @@ import typing_extensions as pytypes_ext
import enum
import sympy as sp
sp.printing.str.StrPrinter._default_settings['abbrev'] = True
## When we str() a unit expression, use abbrevied units.
import sympy.physics.units as spu
import pydantic as pyd
import bpy
from ...utils.blender_type_enum import (
BlenderTypeEnum, append_cls_name_to_values
BlenderTypeEnum, append_cls_name_to_values, wrap_values_in_MT
)
####################
@ -32,13 +36,6 @@ PresetID = pytypes_ext.Annotated[str, pyd.StringConstraints(
pattern=r'^[A-Z_]+$',
)]
####################
# - Generic Types
####################
SocketReturnType = typ.TypeVar('SocketReturnType', covariant=True)
## - Covariance: If B subtypes A, then Container[B] subtypes Container[A].
## - This is absolutely what we want here.
####################
# - Sympy Expression Typing
####################
@ -79,71 +76,287 @@ class TreeType(BlenderTypeEnum):
####################
@append_cls_name_to_values
class SocketType(BlenderTypeEnum):
# Base
Any = enum.auto()
Text = enum.auto()
FilePath = enum.auto()
# Number
IntegerNumber = enum.auto()
RationalNumber = enum.auto()
RealNumber = enum.auto()
ComplexNumber = enum.auto()
# Vector
Real2DVector = enum.auto()
Complex2DVector = enum.auto()
Real3DVector = enum.auto()
Complex3DVector = enum.auto()
# Physical
PhysicalTime = enum.auto()
PhysicalAngle = enum.auto()
PhysicalLength = enum.auto()
PhysicalArea = enum.auto()
PhysicalVolume = enum.auto()
PhysicalMass = enum.auto()
PhysicalSpeed = enum.auto()
PhysicalAccel = enum.auto()
PhysicalForce = enum.auto()
PhysicalPol = enum.auto()
PhysicalFreq = enum.auto()
PhysicalSpecPowerDist = enum.auto()
PhysicalSpecRelPermDist = enum.auto()
# Blender
BlenderObject = enum.auto()
BlenderCollection = enum.auto()
BlenderImage = enum.auto()
BlenderVolume = enum.auto()
BlenderGeoNodes = enum.auto()
BlenderText = enum.auto()
# Maxwell
MaxwellSource = enum.auto()
MaxwellTemporalShape = enum.auto()
MaxwellMedium = enum.auto()
MaxwellMediumNonLinearity = enum.auto()
MaxwellStructure = enum.auto()
MaxwellBound = enum.auto()
MaxwellBoundBox = enum.auto()
MaxwellBoundFace = enum.auto()
MaxwellMonitor = enum.auto()
MaxwellFDTDSim = enum.auto()
MaxwellSimGrid = enum.auto()
MaxwellSimGridAxis = enum.auto()
SocketType_to_units = {
SocketType.PhysicalTime: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalAngle: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalLength: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalArea: {
"default": "UM_SQ",
"values": {
"PM_SQ": spu.pm**2,
"A_SQ": spu.angstrom**2,
"NM_SQ": spu.nm**2,
"UM_SQ": spu.um**2,
"MM_SQ": spu.mm**2,
"CM_SQ": spu.cm**2,
"M_SQ": spu.m**2,
},
},
SocketType.PhysicalVolume: {
"default": "UM_CB",
"values": {
"PM_CB": spu.pm**3,
"A_CB": spu.angstrom**3,
"NM_CB": spu.nm**3,
"UM_CB": spu.um**3,
"MM_CB": spu.mm**3,
"CM_CB": spu.cm**3,
"M_CB": spu.m**3,
"ML": spu.milliliter,
"L": spu.liter,
},
},
SocketType.PhysicalMass: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalSpeed: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalAccel: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalForce: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalPol: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalFreq: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalSpecPowerDist: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
SocketType.PhysicalSpecRelPermDist: {
"default": "UM",
"values": {
"UM": spu.um,
},
},
}
SocketType_to_color = {
SocketType.Any: (0.5, 0.5, 0.5, 1.0),
SocketType.Text: (0.5, 0.5, 0.5, 1.0),
SocketType.FilePath: (0.5, 0.5, 0.5, 1.0),
# Mathematical
SocketType.IntegerNumber: (0.5, 0.5, 0.5, 1.0),
SocketType.RationalNumber: (0.5, 0.5, 0.5, 1.0),
SocketType.RealNumber: (0.5, 0.5, 0.5, 1.0),
SocketType.ComplexNumber: (0.5, 0.5, 0.5, 1.0),
SocketType.Real2DVector: (0.5, 0.5, 0.5, 1.0),
SocketType.Complex2DVector: (0.5, 0.5, 0.5, 1.0),
SocketType.Real3DVector: (0.5, 0.5, 0.5, 1.0),
SocketType.Complex3DVector: (0.5, 0.5, 0.5, 1.0),
# Physical
SocketType.PhysicalTime: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalAngle: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalLength: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalArea: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalVolume: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalMass: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalSpeed: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalAccel: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalForce: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalPol: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalFreq: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalSpecPowerDist: (0.5, 0.5, 0.5, 1.0),
SocketType.PhysicalSpecRelPermDist: (0.5, 0.5, 0.5, 1.0),
# Blender
SocketType.BlenderObject: (0.5, 0.5, 0.5, 1.0),
SocketType.BlenderCollection: (0.5, 0.5, 0.5, 1.0),
SocketType.BlenderImage: (0.5, 0.5, 0.5, 1.0),
SocketType.BlenderVolume: (0.5, 0.5, 0.5, 1.0),
SocketType.BlenderGeoNodes: (0.5, 0.5, 0.5, 1.0),
SocketType.BlenderText: (0.5, 0.5, 0.5, 1.0),
# Maxwell
SocketType.MaxwellSource: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellTemporalShape: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellMedium: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellMediumNonLinearity: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellStructure: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellBoundBox: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellBoundFace: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellMonitor: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellFDTDSim: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellSimGrid: (0.5, 0.5, 0.5, 1.0),
SocketType.MaxwellSimGridAxis: (0.5, 0.5, 0.5, 1.0),
}
####################
# - Node Types
####################
@append_cls_name_to_values
class NodeType(BlenderTypeEnum):
KitchenSink = enum.auto()
# Inputs
## Inputs / Scene
Time = enum.auto()
ObjectInfo = enum.auto()
UnitSystem = enum.auto()
FloatParameter = enum.auto()
ComplexParameter = enum.auto()
Vec3Parameter = enum.auto()
## Inputs / Parameters
NumberParameter = enum.auto()
PhysicalParameter = enum.auto()
## Inputs / Constants
ScientificConstant = enum.auto()
FloatConstant = enum.auto()
ComplexConstant = enum.auto()
Vec3Constant = enum.auto()
NumberConstant = enum.auto()
PhysicalConstant = enum.auto()
BlenderConstant = enum.auto()
FloatArrayElement = enum.auto()
ComplexArrayElement = enum.auto()
Vec3ArrayElement = enum.auto()
## Inputs / Lists
RealList = enum.auto()
ComplexList = enum.auto()
FloatDictElement = enum.auto()
ComplexDictElement = enum.auto()
Vec3DictElement = enum.auto()
## Inputs /
InputFile = enum.auto()
FloatField = enum.auto()
ComplexField = enum.auto()
Vec3Field = enum.auto()
# Outputs
## Outputs / Viewers
ValueViewer = enum.auto()
ConsoleViewer = enum.auto()
## Outputs / Exporters
JSONFileExporter = enum.auto()
# Viz
TemporalShapeViz = enum.auto()
SourceViz = enum.auto()
StructureViz = enum.auto()
BoundViz = enum.auto()
FDTDViz = enum.auto()
# Sources
## Sources / Temporal Shapes
GaussianPulseTemporalShape = enum.auto()
ContinuousWaveTemporalShape = enum.auto()
DataDrivenTemporalShape = enum.auto()
ListTemporalShape = enum.auto()
## Sources /
PointDipoleSource = enum.auto()
UniformCurrentSource = enum.auto()
PlaneWaveSource = enum.auto()
@ -169,124 +382,114 @@ class NodeType(BlenderTypeEnum):
DrudeLorentzMedium = enum.auto()
DebyeMedium = enum.auto()
## Mediums / Non-Linearities
AddNonLinearity = enum.auto()
ChiThreeSusceptibilityNonLinearity = enum.auto()
TwoPhotonAbsorptionNonLinearity = enum.auto()
KerrNonLinearity = enum.auto()
# Structures
TriMeshStructure = enum.auto()
ObjectStructure = enum.auto()
GeoNodesStructure = enum.auto()
ScriptedStructure = enum.auto()
## Structures / Primitives
BoxStructure = enum.auto()
SphereStructure = enum.auto()
CylinderStructure = enum.auto()
GeoNodesStructure = enum.auto()
ScriptedStructure = enum.auto()
# Bounds
BoundBox = enum.auto()
## Bounds / Bound Faces
PMLBoundFace = enum.auto()
PECBoundFace = enum.auto()
PMCBoundFace = enum.auto()
BlochBoundFace = enum.auto()
PeriodicBoundFace = enum.auto()
AbsorbingBoundFace = enum.auto()
# Monitors
EHFieldMonitor = enum.auto()
FieldPowerFluxMonitor = enum.auto()
EpsilonTensorMonitor = enum.auto()
DiffractionMonitor = enum.auto()
## Monitors / Near-Field Projections
CartesianNearFieldProjectionMonitor = enum.auto()
ObservationAngleNearFieldProjectionMonitor = enum.auto()
KSpaceNearFieldProjectionMonitor = enum.auto()
# Simulations
# Sims
SimGrid = enum.auto()
## Sims / Sim Grid Axis
AutomaticSimGridAxis = enum.auto()
ManualSimGridAxis = enum.auto()
UniformSimGridAxis = enum.auto()
ArraySimGridAxis = enum.auto()
## Sim /
FDTDSim = enum.auto()
SimulationGridDiscretization = enum.auto()
Automatic1DGridDiscretization = enum.auto()
Manual1DGridDiscretization = enum.auto()
Uniform1DGridDiscretization = enum.auto()
DataDriven1DGridDiscretization = enum.auto()
# Utilities
FloatMath = enum.auto()
ComplexMath = enum.auto()
Vec3Math = enum.auto()
Math = enum.auto()
FloatFieldMath = enum.auto()
ComplexFieldMath = enum.auto()
Vec3FieldMath = enum.auto()
SpectralMath = enum.auto()
## Utilities / Operations
ArrayOperation = enum.auto()
####################
# - Node Category Types
####################
@wrap_values_in_MT
class NodeCategory(BlenderTypeEnum):
MAXWELL_SIM = enum.auto()
MAXWELLSIM = enum.auto()
# Inputs/
MAXWELL_SIM_INPUTS = enum.auto()
MAXWELL_SIM_INPUTS_SCENE = enum.auto()
MAXWELL_SIM_INPUTS_PARAMETERS = enum.auto()
MAXWELL_SIM_INPUTS_CONSTANTS = enum.auto()
MAXWELL_SIM_INPUTS_ARRAY = enum.auto()
MAXWELL_SIM_INPUTS_ARRAY_ELEMENTS = enum.auto()
MAXWELL_SIM_INPUTS_ARRAY_UNIONS = enum.auto()
MAXWELL_SIM_INPUTS_DICTIONARY = enum.auto()
MAXWELL_SIM_INPUTS_DICTIONARY_ELEMENTS = enum.auto()
MAXWELL_SIM_INPUTS_DICTIONARY_UNIONS = enum.auto()
MAXWELL_SIM_INPUTS_FIELDS = enum.auto()
MAXWELLSIM_INPUTS = enum.auto()
MAXWELLSIM_INPUTS_SCENE = enum.auto()
MAXWELLSIM_INPUTS_PARAMETERS = enum.auto()
MAXWELLSIM_INPUTS_CONSTANTS = enum.auto()
MAXWELLSIM_INPUTS_LISTS = enum.auto()
# Outputs/
MAXWELL_SIM_OUTPUTS = enum.auto()
MAXWELL_SIM_OUTPUTS_VIEWERS = enum.auto()
MAXWELL_SIM_OUTPUTS_EXPORTERS = enum.auto()
# Viz/
MAXWELL_SIM_VIZ = enum.auto()
MAXWELLSIM_OUTPUTS = enum.auto()
MAXWELLSIM_OUTPUTS_VIEWERS = enum.auto()
MAXWELLSIM_OUTPUTS_EXPORTERS = enum.auto()
MAXWELLSIM_OUTPUTS_PLOTTERS = enum.auto()
# Sources/
MAXWELL_SIM_SOURCES = enum.auto()
MAXWELL_SIM_SOURCES_TEMPORALSHAPES = enum.auto()
MAXWELL_SIM_SOURCES_MODELLED = enum.auto()
MAXWELL_SIM_SOURCES_DATADRIVEN = enum.auto()
MAXWELLSIM_SOURCES = enum.auto()
MAXWELLSIM_SOURCES_TEMPORALSHAPES = enum.auto()
# Mediums/
MAXWELL_SIM_MEDIUMS = enum.auto()
MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS = enum.auto()
MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS_DIRECT = enum.auto()
MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS_MODELLED = enum.auto()
MAXWELL_SIM_MEDIUMS_NONLINEARITIES = enum.auto()
MAXWELLSIM_MEDIUMS = enum.auto()
MAXWELLSIM_MEDIUMS_NONLINEARITIES = enum.auto()
# Structures/
MAXWELL_SIM_STRUCTURES = enum.auto()
MAXWELL_SIM_STRUCTURES_PRIMITIES = enum.auto()
MAXWELL_SIM_STRUCTURES_GENERATED = enum.auto()
MAXWELLSIM_STRUCTURES = enum.auto()
MAXWELLSIM_STRUCTURES_PRIMITIVES = enum.auto()
# Bounds/
MAXWELL_SIM_BOUNDS = enum.auto()
MAXWELL_SIM_BOUNDS_BOUNDFACES = enum.auto()
MAXWELLSIM_BOUNDS = enum.auto()
MAXWELLSIM_BOUNDS_BOUNDFACES = enum.auto()
# Monitors/
MAXWELL_SIM_MONITORS = enum.auto()
MAXWELL_SIM_MONITORS_NEARFIELDPROJECTIONS = enum.auto()
MAXWELLSIM_MONITORS = enum.auto()
MAXWELLSIM_MONITORS_NEARFIELDPROJECTIONS = enum.auto()
# Simulations/
MAXWELL_SIM_SIMULATIONS = enum.auto()
MAXWELL_SIM_SIMULATIONS_DISCRETIZATIONS = enum.auto()
MAXWELL_SIM_SIMULATIONS_DISCRETIZATIONS_1DGRID = enum.auto()
MAXWELLSIM_SIMS = enum.auto()
MAXWELLSIM_SIMGRIDAXES = enum.auto()
# Utilities/
MAXWELL_SIM_UTILITIES = enum.auto()
MAXWELL_SIM_UTILITIES_MATH = enum.auto()
MAXWELL_SIM_UTILITIES_FIELDMATH = enum.auto()
MAXWELLSIM_UTILITIES = enum.auto()
MAXWELLSIM_UTILITIES_OPERATIONS = enum.auto()
@classmethod
def get_tree(cls):
@ -294,7 +497,7 @@ class NodeCategory(BlenderTypeEnum):
syllable_categories = [
node_category.value.split("_")
for node_category in cls
if node_category.value != "MAXWELL_SIM"
if node_category.value != "MAXWELLSIM"
]
category_tree = {}
@ -312,61 +515,45 @@ class NodeCategory(BlenderTypeEnum):
NodeCategory_to_category_label = {
# Inputs/
NodeCategory.MAXWELL_SIM_INPUTS: "Inputs",
NodeCategory.MAXWELL_SIM_INPUTS_SCENE: "Scene",
NodeCategory.MAXWELL_SIM_INPUTS_PARAMETERS: "Parameters",
NodeCategory.MAXWELL_SIM_INPUTS_CONSTANTS: "Constants",
NodeCategory.MAXWELL_SIM_INPUTS_ARRAY: "Array",
NodeCategory.MAXWELL_SIM_INPUTS_ARRAY_ELEMENTS: "Elements",
NodeCategory.MAXWELL_SIM_INPUTS_ARRAY_UNIONS: "Unions",
NodeCategory.MAXWELL_SIM_INPUTS_DICTIONARY: "Dictionary",
NodeCategory.MAXWELL_SIM_INPUTS_DICTIONARY_ELEMENTS: "Elements",
NodeCategory.MAXWELL_SIM_INPUTS_DICTIONARY_UNIONS: "Unions",
NodeCategory.MAXWELL_SIM_INPUTS_FIELDS: "Fields",
NodeCategory.MAXWELLSIM_INPUTS: "Inputs",
NodeCategory.MAXWELLSIM_INPUTS_SCENE: "Scene",
NodeCategory.MAXWELLSIM_INPUTS_PARAMETERS: "Parameters",
NodeCategory.MAXWELLSIM_INPUTS_CONSTANTS: "Constants",
NodeCategory.MAXWELLSIM_INPUTS_LISTS: "Lists",
# Outputs/
NodeCategory.MAXWELL_SIM_OUTPUTS: "Outputs",
NodeCategory.MAXWELL_SIM_OUTPUTS_VIEWERS: "Viewers",
NodeCategory.MAXWELL_SIM_OUTPUTS_EXPORTERS: "Exporters",
# Viz/
NodeCategory.MAXWELL_SIM_VIZ: "Viz",
NodeCategory.MAXWELLSIM_OUTPUTS: "Outputs",
NodeCategory.MAXWELLSIM_OUTPUTS_VIEWERS: "Viewers",
NodeCategory.MAXWELLSIM_OUTPUTS_EXPORTERS: "Exporters",
NodeCategory.MAXWELLSIM_OUTPUTS_PLOTTERS: "Plotters",
# Sources/
NodeCategory.MAXWELL_SIM_SOURCES: "Sources",
NodeCategory.MAXWELL_SIM_SOURCES_TEMPORALSHAPES: "Temporal Shapes",
NodeCategory.MAXWELL_SIM_SOURCES_MODELLED: "Modelled",
NodeCategory.MAXWELL_SIM_SOURCES_DATADRIVEN: "Data-Driven",
NodeCategory.MAXWELLSIM_SOURCES: "Sources",
NodeCategory.MAXWELLSIM_SOURCES_TEMPORALSHAPES: "Temporal Shapes",
# Mediums/
NodeCategory.MAXWELL_SIM_MEDIUMS: "Mediums",
NodeCategory.MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS: "Linear Mediums",
NodeCategory.MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS_DIRECT: "Direct",
NodeCategory.MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS_MODELLED: "Modelled",
NodeCategory.MAXWELL_SIM_MEDIUMS_NONLINEARITIES: "Non-Linearities",
NodeCategory.MAXWELLSIM_MEDIUMS: "Mediums",
NodeCategory.MAXWELLSIM_MEDIUMS_NONLINEARITIES: "Non-Linearities",
# Structures/
NodeCategory.MAXWELL_SIM_STRUCTURES: "Structures",
NodeCategory.MAXWELL_SIM_STRUCTURES_PRIMITIES: "Primitives",
NodeCategory.MAXWELL_SIM_STRUCTURES_GENERATED: "Generated",
NodeCategory.MAXWELLSIM_STRUCTURES: "Structures",
NodeCategory.MAXWELLSIM_STRUCTURES_PRIMITIVES: "Primitives",
# Bounds/
NodeCategory.MAXWELL_SIM_BOUNDS: "Bounds",
NodeCategory.MAXWELL_SIM_BOUNDS_BOUNDFACES: "Bound Faces",
NodeCategory.MAXWELLSIM_BOUNDS: "Bounds",
NodeCategory.MAXWELLSIM_BOUNDS_BOUNDFACES: "Bound Faces",
# Monitors/
NodeCategory.MAXWELL_SIM_MONITORS: "Monitors",
NodeCategory.MAXWELL_SIM_MONITORS_NEARFIELDPROJECTIONS: "Near-Field Projections",
NodeCategory.MAXWELLSIM_MONITORS: "Monitors",
NodeCategory.MAXWELLSIM_MONITORS_NEARFIELDPROJECTIONS: "Near-Field Projections",
# Simulations/
NodeCategory.MAXWELL_SIM_SIMULATIONS: "Simulations",
NodeCategory.MAXWELL_SIM_SIMULATIONS_DISCRETIZATIONS: "Discretizations",
NodeCategory.MAXWELL_SIM_SIMULATIONS_DISCRETIZATIONS_1DGRID: "1D Grid Discretizations",
NodeCategory.MAXWELLSIM_SIMS: "Simulations",
NodeCategory.MAXWELLSIM_SIMGRIDAXES: "Sim Grid Axes",
# Utilities/
NodeCategory.MAXWELL_SIM_UTILITIES: "Utilities",
NodeCategory.MAXWELL_SIM_UTILITIES_MATH: "Math",
NodeCategory.MAXWELL_SIM_UTILITIES_FIELDMATH: "Field Math",
NodeCategory.MAXWELLSIM_UTILITIES: "Utilities",
NodeCategory.MAXWELLSIM_UTILITIES_OPERATIONS: "Operations",
}
@ -386,7 +573,11 @@ class PresetDef(pyd.BaseModel):
description: str
values: dict[SocketName, typ.Any]
@typ.runtime_checkable
SocketReturnType = typ.TypeVar('SocketReturnType', covariant=True)
## - Covariance: If B subtypes A, then Container[B] subtypes Container[A].
## - This is absolutely what we want here.
#@typ.runtime_checkable
#class BLSocketProtocol(typ.Protocol):
# socket_type: SocketType
# socket_color: BlenderColorRGB

View File

@ -1,23 +1,36 @@
from . import kitchen_sink
from . import inputs
from . import outputs
from . import sources
from . import mediums
from . import simulations
from . import structures
from . import bounds
from . import monitors
from . import simulations
from . import utilities
BL_REGISTER = [
*kitchen_sink.BL_REGISTER,
*inputs.BL_REGISTER,
*outputs.BL_REGISTER,
*mediums.BL_REGISTER,
*sources.BL_REGISTER,
*simulations.BL_REGISTER,
*mediums.BL_REGISTER,
*structures.BL_REGISTER,
*bounds.BL_REGISTER,
*monitors.BL_REGISTER,
*simulations.BL_REGISTER,
*utilities.BL_REGISTER,
]
BL_NODES = {
**kitchen_sink.BL_NODES,
**inputs.BL_NODES,
**outputs.BL_NODES,
**sources.BL_NODES,
**mediums.BL_NODES,
**simulations.BL_NODES,
**structures.BL_NODES,
**bounds.BL_NODES,
**monitors.BL_NODES,
**simulations.BL_NODES,
**utilities.BL_NODES,
}

View File

@ -79,7 +79,6 @@ class FuncOutputSocket(
# Define Factory Function & Decorator
def computes_output_socket(
output_socket_name: contracts.SocketName,
return_type: typ.Generic[contracts.SocketReturnType],
) -> typ.Callable[
[ComputeOutputSocketFunc[contracts.SocketReturnType]],
FuncOutputSocket[contracts.SocketReturnType],
@ -114,7 +113,7 @@ def computes_output_socket(
####################
# - Node Callbacks
####################
def sync_selected_preset(node: contracts.NodeTypeProtocol) -> None:
def sync_selected_preset(node) -> None:
"""Whenever a preset is set in a NodeTypeProtocol, this function
should be called to overwrite the `default_value`s of the input sockets
with the actual preset values.
@ -123,13 +122,14 @@ def sync_selected_preset(node: contracts.NodeTypeProtocol) -> None:
node: The node for which input socket `default_value`s should be
set to the values defined within the currently selected preset.
"""
if node.preset is None:
msg = f"Node {node} has no preset EnumProperty"
raise ValueError(msg)
if hasattr(node, "preset") and hasattr(node, "presets"):
if node.preset is None:
msg = f"Node {node} has no preset EnumProperty"
raise ValueError(msg)
if node.presets is None:
msg = f"Node {node} has preset EnumProperty, but no defined presets."
raise ValueError(msg)
if node.presets is None:
msg = f"Node {node} has preset EnumProperty, but no defined presets."
raise ValueError(msg)
# Set Input Sockets to Preset Values
preset_def = node.presets[node.preset]
@ -153,6 +153,41 @@ class MaxwellSimTreeNode(bpy.types.Node):
# Set bl_idname
cls.bl_idname = cls.node_type.value
# Declare Node Property: 'preset' EnumProperty
if hasattr(cls, "input_socket_sets") or hasattr(cls, "output_socket_sets"):
if not hasattr(cls, "input_socket_sets"):
cls.input_socket_sets = {}
if not hasattr(cls, "output_socket_sets"):
cls.output_socket_sets = {}
socket_set_keys = [
input_socket_set_key
for input_socket_set_key in cls.input_socket_sets.keys()
]
socket_set_keys += [
output_socket_set_key
for output_socket_set_key in cls.output_socket_sets.keys()
if output_socket_set_key not in socket_set_keys
]
cls.__annotations__["socket_set"] = bpy.props.EnumProperty(
name="",
description="Select a node socket configuration",
items=[
(
socket_set_key,
socket_set_key.capitalize(),
socket_set_key.capitalize(),
)
for socket_set_key in socket_set_keys
],
default=socket_set_keys[0],
update=(lambda self, context: self._update_socket()),
)
cls.__annotations__["socket_set_previous"] = bpy.props.StringProperty(
default=socket_set_keys[0]
)
# Declare Node Property: 'preset' EnumProperty
if hasattr(cls, "presets"):
first_preset = list(cls.presets.keys())[0]
@ -213,6 +248,28 @@ class MaxwellSimTreeNode(bpy.types.Node):
]
socket_def.init(bl_socket)
# Initialize Dynamic Sockets
if hasattr(self, "socket_set"):
if self.socket_set in self.input_socket_sets:
for socket_name, socket_def in self.input_socket_sets[self.socket_set].items():
self.inputs.new(
socket_def.socket_type.value,
socket_def.label,
)
bl_socket = self.inputs[socket_def.label]
socket_def.init(bl_socket)
if self.socket_set in self.output_socket_sets:
for socket_name, socket_def in self.output_socket_sets[self.socket_set].items():
self.outputs.new(
socket_def.socket_type.value,
socket_def.label,
)
bl_socket = self.outputs[socket_def.label]
socket_def.init(bl_socket)
# Sync Default Preset to Input Socket Values
if self.preset is not None:
sync_selected_preset(self)
@ -235,6 +292,47 @@ class MaxwellSimTreeNode(bpy.types.Node):
return ntree.bl_idname == contracts.TreeType.MaxwellSim.value
def _update_socket(self):
if not hasattr(self, "socket_set"):
raise ValueError("no socket")
if self.socket_set == self.socket_set_previous: return
# Delete Old Sockets
if self.socket_set_previous in self.input_socket_sets:
for socket_name, socket_def in self.input_socket_sets[self.socket_set_previous].items():
bl_socket = self.inputs[socket_def.label]
self.inputs.remove(bl_socket)
if self.socket_set_previous in self.output_socket_sets:
for socket_name, socket_def in self.output_socket_sets[self.socket_set_previous].items():
bl_socket = self.outputs[socket_def.label]
self.outputs.remove(bl_socket)
# Add New Sockets
if self.socket_set in self.input_socket_sets:
for socket_name, socket_def in self.input_socket_sets[self.socket_set].items():
self.inputs.new(
socket_def.socket_type.value,
socket_def.label,
)
bl_socket = self.inputs[socket_def.label]
socket_def.init(bl_socket)
if self.socket_set in self.output_socket_sets:
for socket_name, socket_def in self.output_socket_sets[self.socket_set].items():
self.outputs.new(
socket_def.socket_type.value,
socket_def.label,
)
bl_socket = self.outputs[socket_def.label]
socket_def.init(bl_socket)
# Update "Previous"
self.socket_set_previous = self.socket_set
####################
# - UI Methods
####################
@ -250,6 +348,9 @@ class MaxwellSimTreeNode(bpy.types.Node):
if self.preset is not None:
layout.prop(self, "preset", text="")
if hasattr(self, "socket_set"):
layout.prop(self, "socket_set", text="")
if hasattr(self, "draw_operators"):
self.draw_operators(context, layout)

View File

@ -0,0 +1,11 @@
from . import bound_box
from . import bound_faces
BL_REGISTER = [
*bound_box.BL_REGISTER,
*bound_faces.BL_REGISTER,
]
BL_NODES = {
**bound_box.BL_NODES,
**bound_faces.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,26 @@
from . import pml_bound_face
from . import pec_bound_face
from . import pmc_bound_face
from . import bloch_bound_face
from . import periodic_bound_face
from . import absorbing_bound_face
BL_REGISTER = [
*pml_bound_face.BL_REGISTER,
*pec_bound_face.BL_REGISTER,
*pmc_bound_face.BL_REGISTER,
*bloch_bound_face.BL_REGISTER,
*periodic_bound_face.BL_REGISTER,
*absorbing_bound_face.BL_REGISTER,
]
BL_NODES = {
**pml_bound_face.BL_NODES,
**pec_bound_face.BL_NODES,
**pmc_bound_face.BL_NODES,
**bloch_bound_face.BL_NODES,
**periodic_bound_face.BL_NODES,
**absorbing_bound_face.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -1,8 +1,17 @@
from . import constants
from . import lists
from . import parameters
from . import scene
BL_REGISTER = [
*scene.BL_REGISTER,
*constants.BL_REGISTER,
*parameters.BL_REGISTER,
*lists.BL_REGISTER,
]
BL_NODES = {
**scene.BL_NODES,
**constants.BL_NODES,
**parameters.BL_NODES,
**lists.BL_NODES,
}

View File

@ -1,8 +1,17 @@
from . import complex_constant
from . import number_constant
from . import blender_constant
from . import physical_constant
from . import scientific_constant
BL_REGISTER = [
*complex_constant.BL_REGISTER,
*scientific_constant.BL_REGISTER,
*number_constant.BL_REGISTER,
*blender_constant.BL_REGISTER,
*physical_constant.BL_REGISTER,
]
BL_NODES = {
**complex_constant.BL_NODES,
**scientific_constant.BL_NODES,
**number_constant.BL_NODES,
**blender_constant.BL_NODES,
**physical_constant.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -5,27 +5,27 @@ from .... import contracts
from .... import sockets
from ... import base
class ComplexConstantNode(base.MaxwellSimTreeNode):
node_type = contracts.NodeType.ComplexConstant
class NumberConstantNode(base.MaxwellSimTreeNode):
node_type = contracts.NodeType.NumberConstant
bl_label = "Complex Constant"
bl_label = "Numerical Constant"
#bl_icon = constants.ICON_SIM_INPUT
input_sockets = {
"value": sockets.ComplexNumberSocketDef(
label="Complex",
),
), ## TODO: Dynamic number socket!
}
output_sockets = {
"value": sockets.ComplexNumberSocketDef(
label="Complex",
),
), ## TODO: Dynamic number socket!
}
####################
# - Callbacks
####################
@base.computes_output_socket("value", sp.Expr)
@base.computes_output_socket("value")
def compute_value(self: contracts.NodeTypeProtocol) -> sp.Expr:
return self.compute_input("value")
@ -35,10 +35,10 @@ class ComplexConstantNode(base.MaxwellSimTreeNode):
# - Blender Registration
####################
BL_REGISTER = [
ComplexConstantNode,
NumberConstantNode,
]
BL_NODES = {
contracts.NodeType.ComplexConstant: (
contracts.NodeCategory.MAXWELL_SIM_INPUTS_CONSTANTS
contracts.NodeType.NumberConstant: (
contracts.NodeCategory.MAXWELLSIM_INPUTS_CONSTANTS
)
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,11 @@
from . import number_list
from . import physical_list
BL_REGISTER = [
*number_list.BL_REGISTER,
*physical_list.BL_REGISTER,
]
BL_NODES = {
**number_list.BL_NODES,
**physical_list.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,11 @@
from . import number_parameter
from . import physical_parameter
BL_REGISTER = [
*number_parameter.BL_REGISTER,
*physical_parameter.BL_REGISTER,
]
BL_NODES = {
**number_parameter.BL_NODES,
**physical_parameter.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,11 @@
from . import time
from . import unit_system
BL_REGISTER = [
*time.BL_REGISTER,
*unit_system.BL_REGISTER,
]
BL_NODES = {
**time.BL_NODES,
**unit_system.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,90 @@
import tidy3d as td
import sympy as sp
import sympy.physics.units as spu
from .. import contracts
from .. import sockets
from . import base
class KitchenSinkNode(base.MaxwellSimTreeNode):
node_type = contracts.NodeType.KitchenSink
bl_label = "Kitchen Sink"
#bl_icon = ...
####################
# - Sockets
####################
input_sockets = {}
input_socket_sets = {
"basic": {
"basic_any": sockets.AnySocketDef(label="Any"),
"basic_filepath": sockets.FilePathSocketDef(label="FilePath"),
"basic_text": sockets.TextSocketDef(label="Text"),
},
"number": {
"number_integer": sockets.IntegerNumberSocketDef(label="IntegerNumber"),
"number_rational": sockets.RationalNumberSocketDef(label="RationalNumber"),
"number_real": sockets.RealNumberSocketDef(label="RealNumber"),
"number_complex": sockets.ComplexNumberSocketDef(label="ComplexNumber"),
},
"vector": {
"vector_real2dvector": sockets.Real2DVectorSocketDef(label="Real2DVector"),
"vector_complex2dvector": sockets.Complex2DVectorSocketDef(label="Complex2DVector"),
"vector_real3dvector": sockets.Real3DVectorSocketDef(label="Real3DVector"),
"vector_complex3dvector": sockets.Complex3DVectorSocketDef(label="Complex3DVector"),
},
"physical": {
"physical_time": sockets.PhysicalTimeSocketDef(label="PhysicalTime"),
"physical_angle": sockets.PhysicalAngleSocketDef(label="PhysicalAngle"),
"physical_length": sockets.PhysicalLengthSocketDef(label="PhysicalLength"),
"physical_area": sockets.PhysicalAreaSocketDef(label="PhysicalArea"),
"physical_volume": sockets.PhysicalVolumeSocketDef(label="PhysicalVolume"),
"physical_mass": sockets.PhysicalMassSocketDef(label="PhysicalMass"),
"physical_speed": sockets.PhysicalSpeedSocketDef(label="PhysicalSpeed"),
"physical_accel": sockets.PhysicalAccelSocketDef(label="PhysicalAccel"),
"physical_force": sockets.PhysicalForceSocketDef(label="PhysicalForce"),
"physical_pol": sockets.PhysicalPolSocketDef(label="PhysicalPol"),
"physical_freq": sockets.PhysicalFreqSocketDef(label="PhysicalFreq"),
"physical_spec_power_dist": sockets.PhysicalSpecPowerDistSocketDef(label="PhysicalSpecPowerDist"),
"physical_spec_rel_perm_dist": sockets.PhysicalSpecRelPermDistSocketDef(label="PhysicalSpecRelPermDist"),
},
"blender": {
"blender_object": sockets.BlenderObjectSocketDef(label="BlenderObject"),
"blender_collection": sockets.BlenderCollectionSocketDef(label="BlenderCollection"),
"blender_image": sockets.BlenderImageSocketDef(label="BlenderImage"),
"blender_volume": sockets.BlenderVolumeSocketDef(label="BlenderVolume"),
"blender_geonodes": sockets.BlenderGeoNodesSocketDef(label="BlenderGeoNodes"),
"blender_text": sockets.BlenderTextSocketDef(label="BlenderText"),
},
"maxwell": {
"maxwell_source": sockets.MaxwellSourceSocketDef(label="MaxwellSource"),
"maxwell_temporal_shape": sockets.MaxwellTemporalShapeSocketDef(label="MaxwellTemporalShape"),
"maxwell_medium": sockets.MaxwellMediumSocketDef(label="MaxwellMedium"),
#"maxwell_medium_nonlinearity": sockets.MaxwellMediumNonLinearitySocketDef(label="MaxwellMediumNonLinearity"),
"maxwell_structure": sockets.MaxwellMediumSocketDef(label="MaxwellMedium"),
"maxwell_bound_box": sockets.MaxwellBoundBoxSocketDef(label="MaxwellBoundBox"),
"maxwell_bound_face": sockets.MaxwellBoundFaceSocketDef(label="MaxwellBoundFace"),
"maxwell_monitor": sockets.MaxwellMonitorSocketDef(label="MaxwellMonitor"),
"maxwell_monitor": sockets.MaxwellFDTDSimSocketDef(label="MaxwellFDTDSim"),
"maxwell_monitor": sockets.MaxwellSimGridSocketDef(label="MaxwellSimGrid"),
"maxwell_monitor": sockets.MaxwellSimGridAxisSocketDef(label="MaxwellSimGridAxis"),
},
}
output_sockets = {}
output_socket_sets = input_socket_sets
####################
# - Blender Registration
####################
BL_REGISTER = [
KitchenSinkNode,
]
BL_NODES = {
contracts.NodeType.KitchenSink: (
contracts.NodeCategory.MAXWELLSIM_INPUTS
)
}

View File

@ -1,8 +1,47 @@
from . import linear_mediums
from . import library_medium
from . import pec_medium
from . import isotropic_medium
from . import anisotropic_medium
from . import triple_sellmeier_medium
from . import sellmeier_medium
from . import pole_residue_medium
from . import drude_medium
from . import drude_lorentz_medium
from . import debye_medium
from . import non_linearities
BL_REGISTER = [
*linear_mediums.BL_REGISTER,
*library_medium.BL_REGISTER,
*pec_medium.BL_REGISTER,
*isotropic_medium.BL_REGISTER,
*anisotropic_medium.BL_REGISTER,
*triple_sellmeier_medium.BL_REGISTER,
*sellmeier_medium.BL_REGISTER,
*pole_residue_medium.BL_REGISTER,
*drude_medium.BL_REGISTER,
*drude_lorentz_medium.BL_REGISTER,
*debye_medium.BL_REGISTER,
*non_linearities.BL_REGISTER,
]
BL_NODES = {
**linear_mediums.BL_NODES,
**library_medium.BL_NODES,
**pec_medium.BL_NODES,
**isotropic_medium.BL_NODES,
**anisotropic_medium.BL_NODES,
**triple_sellmeier_medium.BL_NODES,
**sellmeier_medium.BL_NODES,
**pole_residue_medium.BL_NODES,
**drude_medium.BL_NODES,
**drude_lorentz_medium.BL_NODES,
**debye_medium.BL_NODES,
**non_linearities.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -1,8 +0,0 @@
from . import triple_sellmeier_medium
BL_REGISTER = [
*triple_sellmeier_medium.BL_REGISTER,
]
BL_NODES = {
**triple_sellmeier_medium.BL_NODES,
}

View File

@ -1,84 +0,0 @@
import bpy
import gpu
import gpu_extras
import sympy.physics.units as spu
from .... import types, constants
from ... import node_base
class TripleSellmeierMediumNode(node_base.MaxwellSimTreeNode):
bl_idname = types.NodeType.TripleSellmeierMedium.value
bl_label = "Triple Sellmeier Medium"
bl_icon = constants.ICON_SIM_MEDIUM
input_sockets = {
"B1": (types.SocketType.RealNumber, "B1"),
"B2": (types.SocketType.RealNumber, "B2"),
"B3": (types.SocketType.RealNumber, "B3"),
"C1": (types.SocketType.DimenArea, "C1"),
"C2": (types.SocketType.DimenArea, "C2"),
"C3": (types.SocketType.DimenArea, "C3"),
}
output_sockets = {
"medium": (types.SocketType.MaxwellMedium, "Medium")
}
input_unit_defaults = {
"B1": None,
"B2": None,
"B3": None,
"C1": spu.um**2,
"C2": spu.um**2,
"C3": spu.um**2,
}
socket_presets = {
"_description": [
('BK7', "BK7 Glass", "Borosilicate crown glass (known as BK7)"),
('FUSED_SILICA', "Fused Silica", "Fused silica aka. SiO2"),
],
"_default": "BK7",
"_values": {
"BK7": {
"B1": 1.03961212,
"B2": 0.231792344,
"B3": 1.01046945,
"C1": 6.00069867e-3 * spu.um**2,
"C2": 2.00179144e-2 * spu.um**2,
"C3": 103.560653 * spu.um**2,
},
"FUSED_SILICA": {
"B1": 0.696166300,
"B2": 0.407942600,
"B3": 0.897479400,
"C1": 4.67914826e-3 * spu.um**2,
"C2": 1.35120631e-2 * spu.um**2,
"C3": 97.9340025 * spu.um**2,
},
}
}
####################
# - Properties
####################
def draw_buttons(self, context, layout):
layout.prop(self, 'preset', text="")
####################
# - Callbacks
####################
@node_base.output_socket_cb("medium")
def compute_medium(self):
pass
####################
# - Blender Registration
####################
BL_REGISTER = [
TripleSellmeierMediumNode,
]
BL_NODES = {
types.NodeType.TripleSellmeierMedium: (
types.NodeCategory.MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS
)
}

View File

@ -0,0 +1,17 @@
from . import add_non_linearity
from . import chi_3_susceptibility_non_linearity
from . import kerr_non_linearity
from . import two_photon_absorption_non_linearity
BL_REGISTER = [
*add_non_linearity.BL_REGISTER,
*chi_3_susceptibility_non_linearity.BL_REGISTER,
*kerr_non_linearity.BL_REGISTER,
*two_photon_absorption_non_linearity.BL_REGISTER,
]
BL_NODES = {
**add_non_linearity.BL_NODES,
**chi_3_susceptibility_non_linearity.BL_NODES,
**kerr_non_linearity.BL_NODES,
**two_photon_absorption_non_linearity.BL_NODES,
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -2,9 +2,9 @@ import tidy3d as td
import sympy as sp
import sympy.physics.units as spu
from .... import contracts
from .... import sockets
from ... import base
from ... import contracts
from ... import sockets
from .. import base
class TripleSellmeierMediumNode(base.MaxwellSimTreeNode):
node_type = contracts.NodeType.TripleSellmeierMedium
@ -23,7 +23,7 @@ class TripleSellmeierMediumNode(base.MaxwellSimTreeNode):
} | {
f"C{i}": sockets.PhysicalAreaSocketDef(
label=f"C{i}",
default_unit="UM_SQ"
default_unit=spu.um**2
)
for i in [1, 2, 3]
}
@ -66,7 +66,7 @@ class TripleSellmeierMediumNode(base.MaxwellSimTreeNode):
####################
# - Output Socket Computation
####################
@base.computes_output_socket("medium", td.Sellmeier)
@base.computes_output_socket("medium")
def compute_medium(self: contracts.NodeTypeProtocol) -> td.Sellmeier:
## Retrieval
#B1 = self.compute_input("B1")
@ -96,6 +96,6 @@ BL_REGISTER = [
]
BL_NODES = {
contracts.NodeType.TripleSellmeierMedium: (
contracts.NodeCategory.MAXWELL_SIM_MEDIUMS_LINEARMEDIUMS
contracts.NodeCategory.MAXWELLSIM_MEDIUMS
)
}

View File

@ -0,0 +1,17 @@
from . import eh_field_monitor
from . import field_power_flux_monitor
from . import epsilon_tensor_monitor
from . import diffraction_monitor
BL_REGISTER = [
*eh_field_monitor.BL_REGISTER,
*field_power_flux_monitor.BL_REGISTER,
*epsilon_tensor_monitor.BL_REGISTER,
*diffraction_monitor.BL_REGISTER,
]
BL_NODES = {
**eh_field_monitor.BL_NODES,
**field_power_flux_monitor.BL_NODES,
**epsilon_tensor_monitor.BL_NODES,
**diffraction_monitor.BL_NODES,
}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -1,4 +1,6 @@
from . import viewers
from . import exporters
from . import plotters
BL_REGISTER = [
*exporters.BL_REGISTER,

View File

@ -106,6 +106,6 @@ BL_REGISTER = [
]
BL_NODES = {
contracts.NodeType.JSONFileExporter: (
contracts.NodeCategory.MAXWELL_SIM_OUTPUTS_EXPORTERS
contracts.NodeCategory.MAXWELLSIM_OUTPUTS_EXPORTERS
)
}

View File

@ -0,0 +1,2 @@
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,11 @@
from . import value_viewer
from . import console_viewer
BL_REGISTER = [
*value_viewer.BL_REGISTER,
*console_viewer.BL_REGISTER,
]
BL_NODES = {
**value_viewer.BL_NODES,
**console_viewer.BL_NODES,
}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -1,8 +1,15 @@
from . import fdtd_simulation
from . import sim_grid
from . import sim_grid_axes
from . import fdtd_sim
BL_REGISTER = [
*fdtd_simulation.BL_REGISTER,
*sim_grid.BL_REGISTER,
*sim_grid_axes.BL_REGISTER,
*fdtd_sim.BL_REGISTER,
]
BL_NODES = {
**fdtd_simulation.BL_NODES,
**sim_grid.BL_NODES,
**sim_grid_axes.BL_NODES,
**fdtd_sim.BL_NODES,
}

View File

@ -41,7 +41,7 @@ class FDTDSimNode(base.MaxwellSimTreeNode):
"structure": sockets.MaxwellStructureSocketDef(
label="Structure",
),
"bound": sockets.MaxwellBoundSocketDef(
"bound": sockets.MaxwellBoundBoxSocketDef(
label="Bound",
),
}
@ -54,7 +54,7 @@ class FDTDSimNode(base.MaxwellSimTreeNode):
####################
# - Output Socket Computation
####################
@base.computes_output_socket("fdtd_sim", td.Sellmeier)
@base.computes_output_socket("fdtd_sim")
def compute_simulation(self: contracts.NodeTypeProtocol) -> td.Simulation:
run_time = self.compute_input("run_time")
ambient_medium = self.compute_input("ambient_medium")
@ -87,6 +87,6 @@ BL_REGISTER = [
]
BL_NODES = {
contracts.NodeType.FDTDSim: (
contracts.NodeCategory.MAXWELL_SIM_SIMULATIONS
contracts.NodeCategory.MAXWELLSIM_SIMS
)
}

View File

@ -0,0 +1,5 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,17 @@
from . import automatic_sim_grid_axis
from . import manual_sim_grid_axis
from . import uniform_sim_grid_axis
from . import array_sim_grid_axis
BL_REGISTER = [
*automatic_sim_grid_axis.BL_REGISTER,
*manual_sim_grid_axis.BL_REGISTER,
*uniform_sim_grid_axis.BL_REGISTER,
*array_sim_grid_axis.BL_REGISTER,
]
BL_NODES = {
**automatic_sim_grid_axis.BL_NODES,
**manual_sim_grid_axis.BL_NODES,
**uniform_sim_grid_axis.BL_NODES,
**array_sim_grid_axis.BL_NODES,
}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

View File

@ -0,0 +1,6 @@
####################
# - Blender Registration
####################
BL_REGISTER = []
BL_NODES = {}

Some files were not shown because too many files have changed in this diff Show More