From 14891cd7ccf18c754e4bcaa552bfd25c00f55e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofus=20Albert=20H=C3=B8gsbro=20Rose?= Date: Mon, 19 Feb 2024 14:28:35 +0100 Subject: [PATCH] feat: Registered all nodes. Also added several features including dynamic sockets in nodes, abstracted units for sockets, and more. --- README.md | 66 ++- .../maxwell_sim_nodes/categories.py | 6 +- .../node_trees/maxwell_sim_nodes/contracts.py | 453 +++++++++++++----- .../maxwell_sim_nodes/nodes/__init__.py | 21 +- .../maxwell_sim_nodes/nodes/base.py | 117 ++++- .../nodes/bounds/__init__.py | 11 + .../nodes/bounds/bound_box.py | 5 + .../nodes/bounds/bound_faces/__init__.py | 26 + .../bound_faces/absorbing_bound_face.py | 5 + .../bounds/bound_faces/bloch_bound_face.py | 5 + .../bounds/bound_faces/pec_bound_face.py | 5 + .../bounds/bound_faces/periodic_bound_face.py | 5 + .../bounds/bound_faces/pmc_bound_face.py | 5 + .../bounds/bound_faces/pml_bound_face.py | 5 + .../nodes/inputs/__init__.py | 9 + .../inputs/array/complex_array_element.py | 0 .../nodes/inputs/array/complex_array_union.py | 0 .../nodes/inputs/array/float_array_element.py | 0 .../nodes/inputs/array/float_array_union.py | 0 .../nodes/inputs/array/vec3_array_element.py | 0 .../nodes/inputs/array/vec3_array_union.py | 0 .../nodes/inputs/constants/__init__.py | 15 +- .../nodes/inputs/constants/area_constant.py | 0 .../inputs/constants/blender_constant.py | 5 + .../nodes/inputs/constants/length_constant.py | 0 ...complex_constant.py => number_constant.py} | 18 +- .../inputs/constants/physical_constant.py | 5 + .../nodes/inputs/constants/real_constant.py | 0 .../inputs/constants/scientific_constant.py | 5 + .../nodes/inputs/constants/vec3_constant.py | 0 .../nodes/inputs/dict/complex_dict_element.py | 0 .../nodes/inputs/dict/complex_dict_union.py | 0 .../nodes/inputs/dict/float_dict_element.py | 0 .../nodes/inputs/dict/float_dict_union.py | 0 .../nodes/inputs/dict/vec3_dict_element.py | 0 .../nodes/inputs/dict/vec3_dict_union.py | 0 .../nodes/inputs/lists/__init__.py | 11 + .../nodes/inputs/lists/number_list.py | 5 + .../nodes/inputs/lists/physical_list.py | 5 + .../nodes/inputs/parameters/__init__.py | 11 + .../inputs/parameters/complex_parameter.py | 0 .../inputs/parameters/float_parameter.py | 0 .../inputs/parameters/number_parameter.py | 5 + .../inputs/parameters/physical_parameter.py | 5 + .../nodes/inputs/parameters/vec3_parameter.py | 0 .../nodes/inputs/scene/__init__.py | 11 + .../nodes/inputs/scene/object_info.py | 0 .../nodes/inputs/scene/time.py | 5 + .../nodes/inputs/scene/unit_system.py | 5 + .../maxwell_sim_nodes/nodes/kitchen_sink.py | 90 ++++ .../nodes/mediums/__init__.py | 45 +- .../nodes/mediums/anisotropic_medium.py | 5 + .../nodes/mediums/debye_medium.py | 6 + .../nodes/mediums/drude_lorentz_medium.py | 6 + .../nodes/mediums/drude_medium.py | 5 + .../nodes/mediums/isotropic_medium.py | 6 + .../nodes/mediums/library_medium.py | 5 + .../nodes/mediums/linear_mediums/__init__.py | 8 - .../mediums/linear_mediums/alternate_idea.py | 84 ---- .../linear_mediums/anisotropic_medium.py | 0 .../mediums/linear_mediums/debye_medium.py | 0 .../linear_mediums/drude_lorentz_medium.py | 0 .../mediums/linear_mediums/drude_medium.py | 0 .../linear_mediums/isotripic_medium.py | 0 .../mediums/linear_mediums/pec_medium.py | 0 .../linear_mediums/pole_residue_medium.py | 0 .../linear_mediums/sellmeier_medium.py | 0 .../nodes/mediums/non_linearities/__init__.py | 17 + .../non_linearities/add_non_linearity.py | 5 + .../chi_3_susceptibility_non_linearity.py | 5 + .../non_linearities/kerr_non_linearity.py | 5 + .../two_photon_absorption_non_linearity.py | 5 + .../nodes/mediums/pec_medium.py | 6 + .../nodes/mediums/pole_residue_medium.py | 6 + .../nodes/mediums/sellmeier_medium.py | 6 + .../triple_sellmeier_medium.py | 12 +- .../nodes/monitors/__init__.py | 17 + .../nodes/monitors/diffraction_monitor.py | 6 + .../nodes/monitors/eh_field_monitor.py | 6 + .../nodes/monitors/epsilon_tensor_monitor.py | 6 + .../monitors/field_power_flux_monitor.py | 6 + .../nodes/outputs/__init__.py | 2 + .../outputs/exporters/json_file_exporter.py | 2 +- .../nodes/outputs/plotters/__init__.py | 2 + .../nodes/outputs/viewer/console_viewer.py | 0 .../nodes/outputs/viewer/value_viewer.py | 0 .../nodes/outputs/viewers/__init__.py | 11 + .../nodes/outputs/viewers/console_viewer.py | 6 + .../nodes/outputs/viewers/value_viewer.py | 6 + .../nodes/simulations/__init__.py | 13 +- .../automatic_1d_grid_discretization.py | 0 .../data_driven_1d_grid_discretization.py | 0 .../manual_1d_grid_discretization.py | 0 .../simulation_grid_discretization.py | 0 .../uniform_1d_grid_discretization.py | 0 .../{fdtd_simulation.py => fdtd_sim.py} | 6 +- .../nodes/simulations/sim_grid.py | 5 + .../simulations/sim_grid_axes/__init__.py | 17 + .../sim_grid_axes/array_sim_grid_axis.py | 6 + .../sim_grid_axes/automatic_sim_grid_axis.py | 6 + .../sim_grid_axes/manual_sim_grid_axis.py | 6 + .../sim_grid_axes/uniform_sim_grid_axis.py | 6 + .../nodes/sources/__init__.py | 25 +- .../astigmatic_gaussian_beam_source.py | 6 + .../data_driven/eh_equivalence_source.py | 0 .../nodes/sources/data_driven/eh_source.py | 0 .../nodes/sources/eh_equivalence_source.py | 6 + .../nodes/sources/eh_source.py | 6 + .../nodes/sources/gaussian_beam_source.py | 6 + .../nodes/sources/modelled/__init__.py | 8 - .../astigmatic_gaussian_beam_source.py | 0 .../sources/modelled/gaussian_beam_source.py | 0 .../nodes/sources/modelled/mode_source.py | 0 .../sources/modelled/plane_wave_source.py | 0 .../nodes/sources/modelled/tfsf_source.py | 0 .../modelled/uniform_current_source.py | 0 .../nodes/sources/plane_wave_source.py | 6 + .../{modelled => }/point_dipole_source.py | 10 +- .../nodes/sources/temporal_shapes/__init__.py | 14 + .../temporal_shapes/array_temporal_shape.py | 6 + .../continuous_wave_temporal_shape.py | 6 + .../data_driven_temporal_shape.py | 6 + .../gaussian_pulse_temporal_shape.py | 6 + .../nodes/sources/tfsf_source.py | 5 + .../nodes/sources/uniform_current_source.py | 6 + .../nodes/structures/__init__.py | 10 + .../generated/geonodes_structure.py | 0 .../generated/scripted_structure.py | 0 .../nodes/structures/geonodes_structure.py | 5 + .../nodes/structures/object_structure.py | 6 + .../nodes/structures/primitives/__init__.py | 6 + .../structures/primitives/box_structure.py | 5 +- .../primitives/cylinder_structure.py | 6 + .../structures/primitives/sphere_structure.py | 6 + .../nodes/structures/scripted_structure.py | 6 + .../nodes/structures/trimesh_structure.py | 0 .../nodes/utilities/__init__.py | 11 + .../field_math/complex_field_math.py | 0 .../utilities/field_math/float_field_math.py | 0 .../utilities/field_math/vec3_field_math.py | 0 .../maxwell_sim_nodes/nodes/utilities/math.py | 5 + .../nodes/utilities/math/complex_math.py | 0 .../nodes/utilities/math/float_math.py | 0 .../nodes/utilities/math/vec3_math.py | 0 .../nodes/utilities/operations/__init__.py | 8 + .../utilities/operations/array_operation.py | 5 + .../nodes/utilities/spectral_math.py | 0 .../maxwell_sim_nodes/nodes/viz/bound_viz.py | 0 .../maxwell_sim_nodes/nodes/viz/fdtd_viz.py | 0 .../maxwell_sim_nodes/nodes/viz/source_viz.py | 0 .../nodes/viz/structure_viz.py | 0 .../nodes/viz/temporal_shape_viz.py | 0 .../maxwell_sim_nodes/sockets/__init__.py | 39 +- .../maxwell_sim_nodes/sockets/base.py | 116 ++++- .../sockets/basic/file_path_socket.py | 4 +- .../sockets/blender/__init__.py | 26 + .../sockets/blender/collection_socket.py | 41 ++ .../sockets/blender/geonodes_socket.py | 41 ++ .../sockets/blender/image_socket.py | 41 ++ .../sockets/blender/object_socket.py | 41 ++ .../sockets/blender/text_socket.py | 41 ++ .../sockets/blender/volume_socket.py | 41 ++ .../sockets/maxwell/__init__.py | 45 +- ...ll_bound_socket.py => bound_box_socket.py} | 16 +- .../sockets/maxwell/bound_face_socket.py | 44 ++ ..._fdtd_sim_socket.py => fdtd_sim_socket.py} | 2 - ...well_medium_socket.py => medium_socket.py} | 2 - .../sockets/maxwell/monitor_socket.py | 44 ++ .../sockets/maxwell/sim_grid_axis_socket.py | 44 ++ .../sockets/maxwell/sim_grid_socket.py | 44 ++ ...well_source_socket.py => source_socket.py} | 2 - ...tructure_socket.py => structure_socket.py} | 2 - .../sockets/maxwell/temporal_shape_socket.py | 40 ++ .../sockets/number/__init__.py | 8 + .../sockets/number/complex_number_socket.py | 6 +- .../sockets/number/integer_number_socket.py | 41 ++ .../sockets/number/rational_number_socket.py | 41 ++ .../sockets/number/real_number_socket.py | 6 +- .../sockets/physical/__init__.py | 55 ++- .../sockets/physical/accel_socket.py | 41 ++ .../sockets/physical/angle_socket.py | 41 ++ ...physical_area_socket.py => area_socket.py} | 77 +-- .../sockets/physical/base.py | 0 .../sockets/physical/force_socket.py | 41 ++ .../sockets/physical/freq_socket.py | 41 ++ .../sockets/physical/length_socket.py | 41 ++ .../sockets/physical/mass_socket.py | 41 ++ .../physical/physical_length_socket.py | 0 .../sockets/physical/physical_mass_socket.py | 0 .../sockets/physical/physical_speed_socket.py | 0 .../sockets/physical/physical_time_socket.py | 0 .../sockets/physical/pol_socket.py | 41 ++ .../physical/spec_power_dist_socket.py | 41 ++ .../physical/spec_rel_permit_dist_socket.py | 41 ++ .../sockets/physical/speed_socket.py | 41 ++ .../sockets/physical/time_socket.py | 41 ++ .../sockets/physical/volume_socket.py | 97 ++++ .../sockets/vector/__init__.py | 18 + .../vector/complex_2d_vector_socket.py | 41 ++ .../vector/complex_3d_vector_socket.py | 41 ++ .../sockets/vector/real_2d_vector_socket.py | 41 ++ .../sockets/vector/real_3d_vector_socket.py | 41 ++ blender_maxwell/utils/blender_type_enum.py | 12 + 203 files changed, 2775 insertions(+), 435 deletions(-) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/complex_array_element.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/complex_array_union.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/float_array_element.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/float_array_union.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/vec3_array_element.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/vec3_array_union.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/area_constant.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/blender_constant.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/length_constant.py rename blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/{complex_constant.py => number_constant.py} (62%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/physical_constant.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/real_constant.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/vec3_constant.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/complex_dict_element.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/complex_dict_union.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/float_dict_element.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/float_dict_union.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/vec3_dict_element.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/vec3_dict_union.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/number_list.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/physical_list.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/complex_parameter.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/float_parameter.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/number_parameter.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/physical_parameter.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/vec3_parameter.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/object_info.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/unit_system.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/kitchen_sink.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/anisotropic_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/debye_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_lorentz_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/isotropic_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/alternate_idea.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/anisotropic_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/debye_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/drude_lorentz_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/drude_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/isotripic_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/pec_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/pole_residue_medium.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/sellmeier_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/add_non_linearity.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/chi_3_susceptibility_non_linearity.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/kerr_non_linearity.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/two_photon_absorption_non_linearity.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pec_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pole_residue_medium.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/sellmeier_medium.py rename blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/{linear_mediums => }/triple_sellmeier_medium.py (90%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/plotters/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewer/console_viewer.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewer/value_viewer.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/console_viewer.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/value_viewer.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/automatic_1d_grid_discretization.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/data_driven_1d_grid_discretization.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/manual_1d_grid_discretization.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/simulation_grid_discretization.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/uniform_1d_grid_discretization.py rename blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/{fdtd_simulation.py => fdtd_sim.py} (92%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/array_sim_grid_axis.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/automatic_sim_grid_axis.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/manual_sim_grid_axis.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/uniform_sim_grid_axis.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/astigmatic_gaussian_beam_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/data_driven/eh_equivalence_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/data_driven/eh_source.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_equivalence_source.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_source.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/gaussian_beam_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/astigmatic_gaussian_beam_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/gaussian_beam_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/mode_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/plane_wave_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/tfsf_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/uniform_current_source.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/plane_wave_source.py rename blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/{modelled => }/point_dipole_source.py (87%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/array_temporal_shape.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/tfsf_source.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/uniform_current_source.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/generated/geonodes_structure.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/generated/scripted_structure.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/geonodes_structure.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/object_structure.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/scripted_structure.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/trimesh_structure.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/__init__.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/complex_field_math.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/float_field_math.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/vec3_field_math.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/complex_math.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/float_math.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/vec3_math.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/array_operation.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/spectral_math.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/bound_viz.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/fdtd_viz.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/source_viz.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/structure_viz.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/temporal_shape_viz.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/collection_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/geonodes_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/image_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/object_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/text_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/volume_socket.py rename blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/{maxwell_bound_socket.py => bound_box_socket.py} (69%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_face_socket.py rename blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/{maxwell_fdtd_sim_socket.py => fdtd_sim_socket.py} (95%) rename blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/{maxwell_medium_socket.py => medium_socket.py} (98%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/monitor_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_axis_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_socket.py rename blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/{maxwell_source_socket.py => source_socket.py} (95%) rename blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/{maxwell_structure_socket.py => structure_socket.py} (96%) create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/temporal_shape_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/integer_number_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/accel_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/angle_socket.py rename blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/{physical_area_socket.py => area_socket.py} (52%) delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/base.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/force_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/freq_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/length_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/mass_socket.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_length_socket.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_mass_socket.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_speed_socket.py delete mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_time_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/pol_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_power_dist_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_rel_permit_dist_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/speed_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/time_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/volume_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/__init__.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_2d_vector_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_3d_vector_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_2d_vector_socket.py create mode 100644 blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_3d_vector_socket.py diff --git a/README.md b/README.md index 98ab2ba..7b30347 100644 --- a/README.md +++ b/README.md @@ -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 - - - 3-Sellmeier Medium - - Sellmeier Medium - - Pole-Residue Medium - - Drude Medium - - Drude-Lorentz Medium - - Debye Medium + - PEC Medium + - Isotropic Medium + - Anisotropic 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 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/categories.py b/blender_maxwell/node_trees/maxwell_sim_nodes/categories.py index 5ad45ed..221a3c9 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/categories.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/categories.py @@ -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. diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/contracts.py b/blender_maxwell/node_trees/maxwell_sim_nodes/contracts.py index 2fffb00..af588d3 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/contracts.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/contracts.py @@ -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 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/__init__.py index 4511cb8..8262f4c 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/__init__.py @@ -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, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/base.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/base.py index fd08654..ea1565a 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/base.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/base.py @@ -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) diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/__init__.py new file mode 100644 index 0000000..104ab56 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_box.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_box.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_box.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_box.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/__init__.py new file mode 100644 index 0000000..281da54 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/absorbing_bound_face.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/absorbing_bound_face.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/absorbing_bound_face.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/absorbing_bound_face.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/bloch_bound_face.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/bloch_bound_face.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/bloch_bound_face.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/bloch_bound_face.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pec_bound_face.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pec_bound_face.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pec_bound_face.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pec_bound_face.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/periodic_bound_face.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/periodic_bound_face.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/periodic_bound_face.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/periodic_bound_face.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pmc_bound_face.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pmc_bound_face.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pmc_bound_face.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pmc_bound_face.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pml_bound_face.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pml_bound_face.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pml_bound_face.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/bounds/bound_faces/pml_bound_face.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/__init__.py index 18e54fb..dbcf5ae 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/__init__.py @@ -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, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/complex_array_element.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/complex_array_element.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/complex_array_union.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/complex_array_union.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/float_array_element.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/float_array_element.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/float_array_union.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/float_array_union.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/vec3_array_element.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/vec3_array_element.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/vec3_array_union.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/array/vec3_array_union.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/__init__.py index 3293f53..eefdd8f 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/__init__.py @@ -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, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/area_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/area_constant.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/blender_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/blender_constant.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/blender_constant.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/length_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/length_constant.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/complex_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/number_constant.py similarity index 62% rename from blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/complex_constant.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/number_constant.py index b5c9dc3..216ff2f 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/complex_constant.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/number_constant.py @@ -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 ) } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/physical_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/physical_constant.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/physical_constant.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/real_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/real_constant.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/scientific_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/scientific_constant.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/scientific_constant.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/scientific_constant.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/vec3_constant.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/constants/vec3_constant.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/complex_dict_element.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/complex_dict_element.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/complex_dict_union.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/complex_dict_union.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/float_dict_element.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/float_dict_element.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/float_dict_union.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/float_dict_union.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/vec3_dict_element.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/vec3_dict_element.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/vec3_dict_union.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/dict/vec3_dict_union.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/__init__.py new file mode 100644 index 0000000..5104639 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/number_list.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/number_list.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/number_list.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/physical_list.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/physical_list.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/lists/physical_list.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/__init__.py new file mode 100644 index 0000000..fb2c2c0 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/complex_parameter.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/complex_parameter.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/float_parameter.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/float_parameter.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/number_parameter.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/number_parameter.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/number_parameter.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/physical_parameter.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/physical_parameter.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/physical_parameter.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/vec3_parameter.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/parameters/vec3_parameter.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/__init__.py new file mode 100644 index 0000000..89db325 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/object_info.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/object_info.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/time.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/time.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/time.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/time.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/unit_system.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/unit_system.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/inputs/scene/unit_system.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/kitchen_sink.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/kitchen_sink.py new file mode 100644 index 0000000..ea41c38 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/kitchen_sink.py @@ -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 + ) +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/__init__.py index a4fd854..5576078 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/__init__.py @@ -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, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/anisotropic_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/anisotropic_medium.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/anisotropic_medium.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/debye_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/debye_medium.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/debye_medium.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_lorentz_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_lorentz_medium.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_lorentz_medium.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_medium.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/drude_medium.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/isotropic_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/isotropic_medium.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/isotropic_medium.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/library_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/library_medium.py index e69de29..41fac16 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/library_medium.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/library_medium.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/__init__.py deleted file mode 100644 index cbc5f80..0000000 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from . import triple_sellmeier_medium - -BL_REGISTER = [ - *triple_sellmeier_medium.BL_REGISTER, -] -BL_NODES = { - **triple_sellmeier_medium.BL_NODES, -} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/alternate_idea.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/alternate_idea.py deleted file mode 100644 index f11b58a..0000000 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/alternate_idea.py +++ /dev/null @@ -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 - ) -} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/anisotropic_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/anisotropic_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/debye_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/debye_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/drude_lorentz_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/drude_lorentz_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/drude_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/drude_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/isotripic_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/isotripic_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/pec_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/pec_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/pole_residue_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/pole_residue_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/sellmeier_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/sellmeier_medium.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/__init__.py new file mode 100644 index 0000000..349eba3 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/add_non_linearity.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/add_non_linearity.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/add_non_linearity.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/chi_3_susceptibility_non_linearity.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/chi_3_susceptibility_non_linearity.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/chi_3_susceptibility_non_linearity.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/kerr_non_linearity.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/kerr_non_linearity.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/kerr_non_linearity.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/two_photon_absorption_non_linearity.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/two_photon_absorption_non_linearity.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/non_linearities/two_photon_absorption_non_linearity.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pec_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pec_medium.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pec_medium.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pole_residue_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pole_residue_medium.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/pole_residue_medium.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/sellmeier_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/sellmeier_medium.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/sellmeier_medium.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/triple_sellmeier_medium.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/triple_sellmeier_medium.py similarity index 90% rename from blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/triple_sellmeier_medium.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/triple_sellmeier_medium.py index abc4aeb..843ac48 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/linear_mediums/triple_sellmeier_medium.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/mediums/triple_sellmeier_medium.py @@ -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 ) } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/__init__.py new file mode 100644 index 0000000..83bda0e --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/diffraction_monitor.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/diffraction_monitor.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/diffraction_monitor.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/diffraction_monitor.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/eh_field_monitor.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/eh_field_monitor.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/eh_field_monitor.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/eh_field_monitor.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/epsilon_tensor_monitor.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/epsilon_tensor_monitor.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/epsilon_tensor_monitor.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/epsilon_tensor_monitor.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/field_power_flux_monitor.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/field_power_flux_monitor.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/field_power_flux_monitor.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/monitors/field_power_flux_monitor.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/__init__.py index 5d3ef72..e47bc45 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/__init__.py @@ -1,4 +1,6 @@ +from . import viewers from . import exporters +from . import plotters BL_REGISTER = [ *exporters.BL_REGISTER, diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/exporters/json_file_exporter.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/exporters/json_file_exporter.py index c6bd439..23bc9f0 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/exporters/json_file_exporter.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/exporters/json_file_exporter.py @@ -106,6 +106,6 @@ BL_REGISTER = [ ] BL_NODES = { contracts.NodeType.JSONFileExporter: ( - contracts.NodeCategory.MAXWELL_SIM_OUTPUTS_EXPORTERS + contracts.NodeCategory.MAXWELLSIM_OUTPUTS_EXPORTERS ) } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/plotters/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/plotters/__init__.py new file mode 100644 index 0000000..9118eb8 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/plotters/__init__.py @@ -0,0 +1,2 @@ +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewer/console_viewer.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewer/console_viewer.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewer/value_viewer.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewer/value_viewer.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/__init__.py new file mode 100644 index 0000000..a520e38 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/console_viewer.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/console_viewer.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/console_viewer.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/value_viewer.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/value_viewer.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/outputs/viewers/value_viewer.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/__init__.py index 6da029d..24da237 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/__init__.py @@ -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, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/automatic_1d_grid_discretization.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/automatic_1d_grid_discretization.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/data_driven_1d_grid_discretization.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/data_driven_1d_grid_discretization.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/manual_1d_grid_discretization.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/manual_1d_grid_discretization.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/simulation_grid_discretization.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/simulation_grid_discretization.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/uniform_1d_grid_discretization.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/discretizations/uniform_1d_grid_discretization.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/fdtd_simulation.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/fdtd_sim.py similarity index 92% rename from blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/fdtd_simulation.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/fdtd_sim.py index 56bd91b..e681efb 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/fdtd_simulation.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/fdtd_sim.py @@ -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 ) } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/__init__.py new file mode 100644 index 0000000..c4ac0e8 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/__init__.py @@ -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, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/array_sim_grid_axis.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/array_sim_grid_axis.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/array_sim_grid_axis.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/automatic_sim_grid_axis.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/automatic_sim_grid_axis.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/automatic_sim_grid_axis.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/manual_sim_grid_axis.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/manual_sim_grid_axis.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/manual_sim_grid_axis.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/uniform_sim_grid_axis.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/uniform_sim_grid_axis.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/simulations/sim_grid_axes/uniform_sim_grid_axis.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/__init__.py index b416f32..1a3fd4d 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/__init__.py @@ -1,8 +1,27 @@ -from . import modelled +from . import temporal_shapes + +from . import point_dipole_source +from . import uniform_current_source +from . import plane_wave_source +from . import gaussian_beam_source +from . import astigmatic_gaussian_beam_source +from . import tfsf_source BL_REGISTER = [ - *modelled.BL_REGISTER, + *temporal_shapes.BL_REGISTER, + *point_dipole_source.BL_REGISTER, + *uniform_current_source.BL_REGISTER, + *plane_wave_source.BL_REGISTER, + *gaussian_beam_source.BL_REGISTER, + *astigmatic_gaussian_beam_source.BL_REGISTER, + *tfsf_source.BL_REGISTER, ] BL_NODES = { - **modelled.BL_NODES, + **temporal_shapes.BL_NODES, + **point_dipole_source.BL_NODES, + **uniform_current_source.BL_NODES, + **plane_wave_source.BL_NODES, + **gaussian_beam_source.BL_NODES, + **astigmatic_gaussian_beam_source.BL_NODES, + **tfsf_source.BL_NODES, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/astigmatic_gaussian_beam_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/astigmatic_gaussian_beam_source.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/astigmatic_gaussian_beam_source.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/data_driven/eh_equivalence_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/data_driven/eh_equivalence_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/data_driven/eh_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/data_driven/eh_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_equivalence_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_equivalence_source.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_equivalence_source.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_source.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/eh_source.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/gaussian_beam_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/gaussian_beam_source.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/gaussian_beam_source.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/__init__.py deleted file mode 100644 index 8cd9029..0000000 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from . import point_dipole_source - -BL_REGISTER = [ - *point_dipole_source.BL_REGISTER, -] -BL_NODES = { - **point_dipole_source.BL_NODES, -} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/astigmatic_gaussian_beam_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/astigmatic_gaussian_beam_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/gaussian_beam_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/gaussian_beam_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/mode_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/mode_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/plane_wave_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/plane_wave_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/tfsf_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/tfsf_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/uniform_current_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/uniform_current_source.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/plane_wave_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/plane_wave_source.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/plane_wave_source.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/point_dipole_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/point_dipole_source.py similarity index 87% rename from blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/point_dipole_source.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/point_dipole_source.py index 8c182c5..655d286 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/modelled/point_dipole_source.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/point_dipole_source.py @@ -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 PointDipoleSourceNode(base.MaxwellSimTreeNode): node_type = contracts.NodeType.PointDipoleSource @@ -38,7 +38,7 @@ class PointDipoleSourceNode(base.MaxwellSimTreeNode): #################### # - Output Socket Computation #################### - @base.computes_output_socket("source", td.PointDipole) + @base.computes_output_socket("source") def compute_source(self: contracts.NodeTypeProtocol) -> td.PointDipole: center = ( self.compute_input("center_x"), @@ -65,6 +65,6 @@ BL_REGISTER = [ ] BL_NODES = { contracts.NodeType.PointDipoleSource: ( - contracts.NodeCategory.MAXWELL_SIM_SOURCES_MODELLED + contracts.NodeCategory.MAXWELLSIM_SOURCES ) } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/__init__.py new file mode 100644 index 0000000..6ff27eb --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/__init__.py @@ -0,0 +1,14 @@ +from . import gaussian_pulse_temporal_shape +from . import continuous_wave_temporal_shape +from . import array_temporal_shape + +BL_REGISTER = [ + *gaussian_pulse_temporal_shape.BL_REGISTER, + *continuous_wave_temporal_shape.BL_REGISTER, + *array_temporal_shape.BL_REGISTER, +] +BL_NODES = { + **gaussian_pulse_temporal_shape.BL_NODES, + **continuous_wave_temporal_shape.BL_NODES, + **array_temporal_shape.BL_NODES, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/array_temporal_shape.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/array_temporal_shape.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/array_temporal_shape.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/continuous_wave_temporal_shape.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/continuous_wave_temporal_shape.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/continuous_wave_temporal_shape.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/continuous_wave_temporal_shape.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/data_driven_temporal_shape.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/data_driven_temporal_shape.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/data_driven_temporal_shape.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/data_driven_temporal_shape.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/gaussian_pulse_temporal_shape.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/gaussian_pulse_temporal_shape.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/gaussian_pulse_temporal_shape.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/temporal_shapes/gaussian_pulse_temporal_shape.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/tfsf_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/tfsf_source.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/tfsf_source.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/uniform_current_source.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/uniform_current_source.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/sources/uniform_current_source.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/__init__.py index edc6d9c..6374ddc 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/__init__.py @@ -1,8 +1,18 @@ +from . import object_structure +from . import geonodes_structure +from . import scripted_structure + from . import primitives BL_REGISTER = [ + *object_structure.BL_REGISTER, + *geonodes_structure.BL_REGISTER, + *scripted_structure.BL_REGISTER, *primitives.BL_REGISTER, ] BL_NODES = { + **object_structure.BL_NODES, + **geonodes_structure.BL_NODES, + **scripted_structure.BL_NODES, **primitives.BL_NODES, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/generated/geonodes_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/generated/geonodes_structure.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/generated/scripted_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/generated/scripted_structure.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/geonodes_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/geonodes_structure.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/geonodes_structure.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/object_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/object_structure.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/object_structure.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/__init__.py index 8413691..e880562 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/__init__.py @@ -1,8 +1,14 @@ from . import box_structure +from . import cylinder_structure +from . import sphere_structure BL_REGISTER = [ *box_structure.BL_REGISTER, + *cylinder_structure.BL_REGISTER, + *sphere_structure.BL_REGISTER, ] BL_NODES = { **box_structure.BL_NODES, + **cylinder_structure.BL_NODES, + **sphere_structure.BL_NODES, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/box_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/box_structure.py index 731a945..d550c69 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/box_structure.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/box_structure.py @@ -8,7 +8,6 @@ from ... import base class BoxStructureNode(base.MaxwellSimTreeNode): node_type = contracts.NodeType.BoxStructure - bl_label = "Box Structure" #bl_icon = ... @@ -53,7 +52,7 @@ class BoxStructureNode(base.MaxwellSimTreeNode): #################### # - Output Socket Computation #################### - @base.computes_output_socket("structure", td.Box) + @base.computes_output_socket("structure") def compute_simulation(self: contracts.NodeTypeProtocol) -> td.Box: medium = self.compute_input("medium") center = ( @@ -85,6 +84,6 @@ BL_REGISTER = [ ] BL_NODES = { contracts.NodeType.BoxStructure: ( - contracts.NodeCategory.MAXWELL_SIM_STRUCTURES_PRIMITIES + contracts.NodeCategory.MAXWELLSIM_STRUCTURES ) } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/cylinder_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/cylinder_structure.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/cylinder_structure.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/cylinder_structure.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/sphere_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/sphere_structure.py index e69de29..8f4a665 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/sphere_structure.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/primitives/sphere_structure.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/scripted_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/scripted_structure.py new file mode 100644 index 0000000..8f4a665 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/scripted_structure.py @@ -0,0 +1,6 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} + diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/trimesh_structure.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/structures/trimesh_structure.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/__init__.py new file mode 100644 index 0000000..c8540a7 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/__init__.py @@ -0,0 +1,11 @@ +from . import math +from . import operations + +BL_REGISTER = [ + *math.BL_REGISTER, + *operations.BL_REGISTER, +] +BL_NODES = { + **math.BL_NODES, + **operations.BL_NODES, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/complex_field_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/complex_field_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/float_field_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/float_field_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/vec3_field_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/field_math/vec3_field_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/complex_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/complex_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/float_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/float_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/vec3_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/math/vec3_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/__init__.py new file mode 100644 index 0000000..d302987 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/__init__.py @@ -0,0 +1,8 @@ +from . import array_operation + +BL_REGISTER = [ + *array_operation.BL_REGISTER, +] +BL_NODES = { + **array_operation.BL_NODES, +} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/array_operation.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/array_operation.py new file mode 100644 index 0000000..41fac16 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/operations/array_operation.py @@ -0,0 +1,5 @@ +#################### +# - Blender Registration +#################### +BL_REGISTER = [] +BL_NODES = {} diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/spectral_math.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/utilities/spectral_math.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/bound_viz.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/bound_viz.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/fdtd_viz.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/fdtd_viz.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/source_viz.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/source_viz.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/structure_viz.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/structure_viz.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/temporal_shape_viz.py b/blender_maxwell/node_trees/maxwell_sim_nodes/nodes/viz/temporal_shape_viz.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/__init__.py index e2cd105..d61eb79 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/__init__.py @@ -4,22 +4,57 @@ TextSocketDef = basic.TextSocketDef FilePathSocketDef = basic.FilePathSocketDef from . import number +IntegerNumberSocketDef = number.IntegerNumberSocketDef +RationalNumberSocketDef = number.RationalNumberSocketDef RealNumberSocketDef = number.RealNumberSocketDef ComplexNumberSocketDef = number.ComplexNumberSocketDef +from . import vector +Real2DVectorSocketDef = vector.Real2DVectorSocketDef +Complex2DVectorSocketDef = vector.Complex2DVectorSocketDef +Real3DVectorSocketDef = vector.Real3DVectorSocketDef +Complex3DVectorSocketDef = vector.Complex3DVectorSocketDef + from . import physical +PhysicalTimeSocketDef = physical.PhysicalTimeSocketDef +PhysicalAngleSocketDef = physical.PhysicalAngleSocketDef +PhysicalLengthSocketDef = physical.PhysicalLengthSocketDef PhysicalAreaSocketDef = physical.PhysicalAreaSocketDef +PhysicalVolumeSocketDef = physical.PhysicalVolumeSocketDef +PhysicalMassSocketDef = physical.PhysicalMassSocketDef +PhysicalSpeedSocketDef = physical.PhysicalSpeedSocketDef +PhysicalAccelSocketDef = physical.PhysicalAccelSocketDef +PhysicalForceSocketDef = physical.PhysicalForceSocketDef +PhysicalPolSocketDef = physical.PhysicalPolSocketDef +PhysicalFreqSocketDef = physical.PhysicalFreqSocketDef +PhysicalSpecRelPermDistSocketDef = physical.PhysicalSpecRelPermDistSocketDef +PhysicalSpecPowerDistSocketDef = physical.PhysicalSpecPowerDistSocketDef + +from . import blender +BlenderObjectSocketDef = blender.BlenderObjectSocketDef +BlenderCollectionSocketDef = blender.BlenderCollectionSocketDef +BlenderImageSocketDef = blender.BlenderImageSocketDef +BlenderVolumeSocketDef = blender.BlenderVolumeSocketDef +BlenderGeoNodesSocketDef = blender.BlenderGeoNodesSocketDef +BlenderTextSocketDef = blender.BlenderTextSocketDef from . import maxwell -MaxwellBoundSocketDef = maxwell.MaxwellBoundSocketDef -MaxwellFDTDSimSocketDef = maxwell.MaxwellFDTDSimSocketDef +MaxwellBoundBoxSocketDef = maxwell.MaxwellBoundBoxSocketDef +MaxwellBoundFaceSocketDef = maxwell.MaxwellBoundFaceSocketDef MaxwellMediumSocketDef = maxwell.MaxwellMediumSocketDef MaxwellSourceSocketDef = maxwell.MaxwellSourceSocketDef +MaxwellTemporalShapeSocketDef = maxwell.MaxwellTemporalShapeSocketDef MaxwellStructureSocketDef = maxwell.MaxwellStructureSocketDef +MaxwellMonitorSocketDef = maxwell.MaxwellMonitorSocketDef +MaxwellFDTDSimSocketDef = maxwell.MaxwellFDTDSimSocketDef +MaxwellSimGridSocketDef = maxwell.MaxwellSimGridSocketDef +MaxwellSimGridAxisSocketDef = maxwell.MaxwellSimGridAxisSocketDef BL_REGISTER = [ *basic.BL_REGISTER, *number.BL_REGISTER, + *vector.BL_REGISTER, *physical.BL_REGISTER, + *blender.BL_REGISTER, *maxwell.BL_REGISTER, ] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/base.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/base.py index 3888c5a..9655cf1 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/base.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/base.py @@ -1,6 +1,8 @@ import typing as typ import bpy +import sympy as sp +import sympy.physics.units as spu from .. import contracts class BLSocket(bpy.types.NodeSocket): @@ -14,6 +16,35 @@ class BLSocket(bpy.types.NodeSocket): # Set bl_idname cls.bl_idname = cls.socket_type.value + cls.socket_color = contracts.SocketType_to_color[ + cls.socket_type.value + ] + + # Configure Use of Units + if ( + hasattr(cls, "use_units") + and cls.socket_type in contracts.SocketType_to_units + ): + # Set Unit Properties + cls.__annotations__["raw_unit"] = bpy.props.EnumProperty( + name="Unit", + description="Choose a unit", + items=[ + (unit_name, str(unit_value), str(unit_value)) + for unit_name, unit_value in contracts.SocketType_to_units[ + cls.socket_type + ]["values"].items() + ], + default=contracts.SocketType_to_units[ + cls.socket_type + ]["default"], + update=lambda self, context: self._update_unit(), + ) + cls.__annotations__["raw_unit_previous"] = bpy.props.StringProperty( + default=contracts.SocketType_to_units[ + cls.socket_type + ]["default"] + ) # Declare Node Property: 'preset' EnumProperty if hasattr(cls, "draw_preview"): @@ -23,16 +54,99 @@ class BLSocket(bpy.types.NodeSocket): default=False, ) + #################### + # - Internal Methods + #################### + @property + def units(self) -> dict[str, sp.Expr]: + return contracts.SocketType_to_units[ + self.socket_type + ]["values"] + + @property + def unit(self) -> sp.Expr: + return contracts.SocketType_to_units[ + self.socket_type + ]["values"][self.raw_unit] + + @unit.setter + def unit(self, value) -> sp.Expr: + raw_unit_name = [ + raw_unit_name + for raw_unit_name, unit_value in contracts.SocketType_to_units[ + self.socket_type + ]["values"].items() + if value == unit_value + ][0] + + self.raw_unit = raw_unit_name + + @property + def _unit_previous(self) -> sp.Expr: + return contracts.SocketType_to_units[ + self.socket_type + ]["values"][self.raw_unit_previous] + + @_unit_previous.setter + def _unit_previous(self, value) -> sp.Expr: + raw_unit_name = [ + raw_unit_name + for raw_unit_name, unit_value in contracts.SocketType_to_units[ + self.socket_type + ]["values"].items() + if value == unit_value + ][0] + + self.raw_unit_previous = raw_unit_name + + def value_as_unit(self, value) -> typ.Any: + """Return the given value expresse as the current internal unit, + without the unit. + """ + + if hasattr(self, "raw_value") and hasattr(self, "unit"): + # (Guard) Value Compatibility + if not self.is_compatible(value): + msg = f"Tried setting socket ({self}) to incompatible value ({value}) of type {type(value)}" + raise ValueError(msg) + + # Return Converted Unit + return spu.convert_to( + value, self.unit + ) / self.unit + else: + raise ValueError("Tried to get 'raw_value_as_unit', but class has no 'raw_value'") + + def _update_unit(self) -> None: + """Convert (if needed) the `raw_value` property, to use the unit + set in the `unit` property. + + If the `raw_value` property isn't set, this only sets "unit_previous". + + Run right after setting the `unit` property, in order to synchronize + the value with the new unit. + """ + if hasattr(self, "raw_value") and hasattr(self, "unit"): + self.raw_value = spu.convert_to( + self.raw_value * self._unit_previous, + self.unit, + ) / self.unit + + self._unit_previous = self.unit + #################### # - Methods #################### def is_compatible(self, value: typ.Any) -> bool: + if not hasattr(self, "compatible_types"): + return True + for compatible_type, checks in self.compatible_types.items(): if ( compatible_type is typ.Any or isinstance(value, compatible_type) ): - return all(check(value) for check in checks) + return all(check(self, value) for check in checks) return False diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/basic/file_path_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/basic/file_path_socket.py index 9516cfe..5edf3c6 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/basic/file_path_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/basic/file_path_socket.py @@ -13,8 +13,6 @@ from ... import contracts #################### class FilePathBLSocket(base.BLSocket): socket_type = contracts.SocketType.FilePath - socket_color = (0.2, 0.2, 0.2, 1.0) - bl_label = "File Path" compatible_types = { @@ -71,7 +69,7 @@ class FilePathSocketDef(pyd.BaseModel): socket_type: contracts.SocketType = contracts.SocketType.FilePath label: str - default_path: Path + default_path: Path = Path("") def init(self, bl_socket: FilePathBLSocket) -> None: bl_socket.default_value = self.default_path diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/__init__.py new file mode 100644 index 0000000..9442a56 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/__init__.py @@ -0,0 +1,26 @@ +from . import object_socket +from . import collection_socket +BlenderObjectSocketDef = object_socket.BlenderObjectSocketDef +BlenderCollectionSocketDef = collection_socket.BlenderCollectionSocketDef + +from . import image_socket +from . import volume_socket +BlenderImageSocketDef = image_socket.BlenderImageSocketDef +BlenderVolumeSocketDef = volume_socket.BlenderVolumeSocketDef + +from . import geonodes_socket +from . import text_socket +BlenderGeoNodesSocketDef = geonodes_socket.BlenderGeoNodesSocketDef +BlenderTextSocketDef = text_socket.BlenderTextSocketDef + + +BL_REGISTER = [ + *object_socket.BL_REGISTER, + *collection_socket.BL_REGISTER, + + *image_socket.BL_REGISTER, + *volume_socket.BL_REGISTER, + + *geonodes_socket.BL_REGISTER, + *text_socket.BL_REGISTER, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/collection_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/collection_socket.py new file mode 100644 index 0000000..8243375 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/collection_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class BlenderCollectionBLSocket(base.BLSocket): + socket_type = contracts.SocketType.BlenderCollection + bl_label = "BlenderCollection" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class BlenderCollectionSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.BlenderCollection + label: str + + def init(self, bl_socket: BlenderCollectionBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + BlenderCollectionBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/geonodes_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/geonodes_socket.py new file mode 100644 index 0000000..13fb4f9 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/geonodes_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class BlenderGeoNodesBLSocket(base.BLSocket): + socket_type = contracts.SocketType.BlenderGeoNodes + bl_label = "BlenderGeoNodes" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class BlenderGeoNodesSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.BlenderGeoNodes + label: str + + def init(self, bl_socket: BlenderGeoNodesBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + BlenderGeoNodesBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/image_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/image_socket.py new file mode 100644 index 0000000..247cadb --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/image_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class BlenderImageBLSocket(base.BLSocket): + socket_type = contracts.SocketType.BlenderImage + bl_label = "BlenderImage" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class BlenderImageSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.BlenderImage + label: str + + def init(self, bl_socket: BlenderImageBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + BlenderImageBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/object_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/object_socket.py new file mode 100644 index 0000000..69e7284 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/object_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class BlenderObjectBLSocket(base.BLSocket): + socket_type = contracts.SocketType.BlenderObject + bl_label = "BlenderObject" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class BlenderObjectSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.BlenderObject + label: str + + def init(self, bl_socket: BlenderObjectBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + BlenderObjectBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/text_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/text_socket.py new file mode 100644 index 0000000..0c95c84 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/text_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class BlenderTextBLSocket(base.BLSocket): + socket_type = contracts.SocketType.BlenderText + bl_label = "BlenderText" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class BlenderTextSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.BlenderText + label: str + + def init(self, bl_socket: BlenderTextBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + BlenderTextBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/volume_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/volume_socket.py new file mode 100644 index 0000000..c0bfc1c --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/blender/volume_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class BlenderVolumeBLSocket(base.BLSocket): + socket_type = contracts.SocketType.BlenderVolume + bl_label = "BlenderVolume" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class BlenderVolumeSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.BlenderVolume + label: str + + def init(self, bl_socket: BlenderVolumeBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + BlenderVolumeBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/__init__.py index 3c36818..c09a292 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/__init__.py @@ -1,23 +1,38 @@ -from . import maxwell_bound_socket -MaxwellBoundSocketDef = maxwell_bound_socket.MaxwellBoundSocketDef +from . import bound_box_socket +from . import bound_face_socket +MaxwellBoundBoxSocketDef = bound_box_socket.MaxwellBoundBoxSocketDef +MaxwellBoundFaceSocketDef = bound_face_socket.MaxwellBoundFaceSocketDef -from . import maxwell_fdtd_sim_socket -MaxwellFDTDSimSocketDef = maxwell_fdtd_sim_socket.MaxwellFDTDSimSocketDef +from . import medium_socket +MaxwellMediumSocketDef = medium_socket.MaxwellMediumSocketDef -from . import maxwell_medium_socket -MaxwellMediumSocketDef = maxwell_medium_socket.MaxwellMediumSocketDef +from . import source_socket +from . import temporal_shape_socket +MaxwellSourceSocketDef = source_socket.MaxwellSourceSocketDef +MaxwellTemporalShapeSocketDef = temporal_shape_socket.MaxwellTemporalShapeSocketDef -from . import maxwell_source_socket -MaxwellSourceSocketDef = maxwell_source_socket.MaxwellSourceSocketDef +from . import structure_socket +MaxwellStructureSocketDef = structure_socket.MaxwellStructureSocketDef -from . import maxwell_structure_socket -MaxwellStructureSocketDef = maxwell_structure_socket.MaxwellStructureSocketDef +from . import monitor_socket +MaxwellMonitorSocketDef = monitor_socket.MaxwellMonitorSocketDef + +from . import fdtd_sim_socket +from . import sim_grid_socket +from . import sim_grid_axis_socket +MaxwellFDTDSimSocketDef = fdtd_sim_socket.MaxwellFDTDSimSocketDef +MaxwellSimGridSocketDef = sim_grid_socket.MaxwellSimGridSocketDef +MaxwellSimGridAxisSocketDef = sim_grid_axis_socket.MaxwellSimGridAxisSocketDef BL_REGISTER = [ - *maxwell_bound_socket.BL_REGISTER, - *maxwell_fdtd_sim_socket.BL_REGISTER, - *maxwell_medium_socket.BL_REGISTER, - *maxwell_source_socket.BL_REGISTER, - *maxwell_structure_socket.BL_REGISTER, + *bound_box_socket.BL_REGISTER, + *bound_face_socket.BL_REGISTER, + *medium_socket.BL_REGISTER, + *source_socket.BL_REGISTER, + *temporal_shape_socket.BL_REGISTER, + *structure_socket.BL_REGISTER, + *fdtd_sim_socket.BL_REGISTER, + *sim_grid_socket.BL_REGISTER, + *sim_grid_axis_socket.BL_REGISTER, ] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_bound_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_box_socket.py similarity index 69% rename from blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_bound_socket.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_box_socket.py index 8192a09..83edf0b 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_bound_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_box_socket.py @@ -7,11 +7,9 @@ import tidy3d as td from .. import base from ... import contracts -class MaxwellBoundBLSocket(base.BLSocket): - socket_type = contracts.SocketType.MaxwellBound - socket_color = (0.8, 0.8, 0.4, 1.0) - - bl_label = "Maxwell Bound" +class MaxwellBoundBoxBLSocket(base.BLSocket): + socket_type = contracts.SocketType.MaxwellBoundBox + bl_label = "Maxwell Bound Box" compatible_types = { td.BoundarySpec: {} @@ -31,16 +29,16 @@ class MaxwellBoundBLSocket(base.BLSocket): #################### # - Socket Configuration #################### -class MaxwellBoundSocketDef(pyd.BaseModel): - socket_type: contracts.SocketType = contracts.SocketType.MaxwellBound +class MaxwellBoundBoxSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.MaxwellBoundBox label: str - def init(self, bl_socket: MaxwellBoundBLSocket) -> None: + def init(self, bl_socket: MaxwellBoundBoxBLSocket) -> None: pass #################### # - Blender Registration #################### BL_REGISTER = [ - MaxwellBoundBLSocket, + MaxwellBoundBoxBLSocket, ] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_face_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_face_socket.py new file mode 100644 index 0000000..bab67ae --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/bound_face_socket.py @@ -0,0 +1,44 @@ +import typing as typ + +import bpy +import pydantic as pyd +import tidy3d as td + +from .. import base +from ... import contracts + +class MaxwellBoundFaceBLSocket(base.BLSocket): + socket_type = contracts.SocketType.MaxwellBoundFace + bl_label = "Maxwell Bound Face" + + compatible_types = { + td.BoundarySpec: {} + } + + #################### + # - Computation of Default Value + #################### + @property + def default_value(self) -> td.BoundarySpec: + return td.BoundarySpec() + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + return None + +#################### +# - Socket Configuration +#################### +class MaxwellBoundFaceSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.MaxwellBoundFace + label: str + + def init(self, bl_socket: MaxwellBoundFaceBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + MaxwellBoundFaceBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_fdtd_sim_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/fdtd_sim_socket.py similarity index 95% rename from blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_fdtd_sim_socket.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/fdtd_sim_socket.py index 5aecc8e..f70cb1e 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_fdtd_sim_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/fdtd_sim_socket.py @@ -9,8 +9,6 @@ from ... import contracts class MaxwellFDTDSimBLSocket(base.BLSocket): socket_type = contracts.SocketType.MaxwellFDTDSim - socket_color = (0.8, 0.8, 0.4, 1.0) - bl_label = "Maxwell Source" compatible_types = { diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_medium_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/medium_socket.py similarity index 98% rename from blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_medium_socket.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/medium_socket.py index 97f7f53..4929229 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_medium_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/medium_socket.py @@ -9,8 +9,6 @@ from ... import contracts class MaxwellMediumBLSocket(base.BLSocket): socket_type = contracts.SocketType.MaxwellMedium - socket_color = (0.8, 0.8, 0.4, 1.0) - bl_label = "Maxwell Medium" compatible_types = { diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/monitor_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/monitor_socket.py new file mode 100644 index 0000000..bb02841 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/monitor_socket.py @@ -0,0 +1,44 @@ +import typing as typ + +import bpy +import pydantic as pyd +import tidy3d as td + +from .. import base +from ... import contracts + +class MaxwellMonitorBLSocket(base.BLSocket): + socket_type = contracts.SocketType.MaxwellMonitor + bl_label = "Maxwell Bound Box" + + compatible_types = { + td.BoundarySpec: {} + } + + #################### + # - Computation of Default Value + #################### + @property + def default_value(self) -> td.BoundarySpec: + return td.BoundarySpec() + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + return None + +#################### +# - Socket Configuration +#################### +class MaxwellMonitorSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.MaxwellMonitor + label: str + + def init(self, bl_socket: MaxwellMonitorBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + MaxwellMonitorBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_axis_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_axis_socket.py new file mode 100644 index 0000000..25d84a4 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_axis_socket.py @@ -0,0 +1,44 @@ +import typing as typ + +import bpy +import pydantic as pyd +import tidy3d as td + +from .. import base +from ... import contracts + +class MaxwellSimGridAxisBLSocket(base.BLSocket): + socket_type = contracts.SocketType.MaxwellSimGridAxis + bl_label = "Maxwell Bound Box" + + compatible_types = { + td.BoundarySpec: {} + } + + #################### + # - Computation of Default Value + #################### + @property + def default_value(self) -> td.BoundarySpec: + return td.BoundarySpec() + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + return None + +#################### +# - Socket Configuration +#################### +class MaxwellSimGridAxisSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.MaxwellSimGridAxis + label: str + + def init(self, bl_socket: MaxwellSimGridAxisBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + MaxwellSimGridAxisBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_socket.py new file mode 100644 index 0000000..57a3887 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/sim_grid_socket.py @@ -0,0 +1,44 @@ +import typing as typ + +import bpy +import pydantic as pyd +import tidy3d as td + +from .. import base +from ... import contracts + +class MaxwellSimGridBLSocket(base.BLSocket): + socket_type = contracts.SocketType.MaxwellSimGrid + bl_label = "Maxwell Bound Box" + + compatible_types = { + td.BoundarySpec: {} + } + + #################### + # - Computation of Default Value + #################### + @property + def default_value(self) -> td.BoundarySpec: + return td.BoundarySpec() + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + return None + +#################### +# - Socket Configuration +#################### +class MaxwellSimGridSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.MaxwellSimGrid + label: str + + def init(self, bl_socket: MaxwellSimGridBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + MaxwellSimGridBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_source_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/source_socket.py similarity index 95% rename from blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_source_socket.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/source_socket.py index 49ed8e8..ed8f642 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_source_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/source_socket.py @@ -9,8 +9,6 @@ from ... import contracts class MaxwellSourceBLSocket(base.BLSocket): socket_type = contracts.SocketType.MaxwellSource - socket_color = (0.8, 0.8, 0.4, 1.0) - bl_label = "Maxwell Source" compatible_types = { diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_structure_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/structure_socket.py similarity index 96% rename from blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_structure_socket.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/structure_socket.py index 801f1f7..6098ac1 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/maxwell_structure_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/structure_socket.py @@ -9,8 +9,6 @@ from ... import contracts class MaxwellStructureBLSocket(base.BLSocket): socket_type = contracts.SocketType.MaxwellStructure - socket_color = (0.8, 0.8, 0.4, 1.0) - bl_label = "Maxwell Structure" compatible_types = { diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/temporal_shape_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/temporal_shape_socket.py new file mode 100644 index 0000000..0f4760a --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/maxwell/temporal_shape_socket.py @@ -0,0 +1,40 @@ +import typing as typ + +import bpy +import pydantic as pyd +import tidy3d as td + +from .. import base +from ... import contracts + +class MaxwellTemporalShapeBLSocket(base.BLSocket): + socket_type = contracts.SocketType.MaxwellTemporalShape + bl_label = "Maxwell Temporal Shape" + + #################### + # - Computation of Default Value + #################### + @property + def default_value(self) -> td.Medium: + return None + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class MaxwellTemporalShapeSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.MaxwellTemporalShape + label: str + + def init(self, bl_socket: MaxwellTemporalShapeBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + MaxwellTemporalShapeBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/__init__.py index 6a946e5..e07df32 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/__init__.py @@ -1,3 +1,9 @@ +from . import integer_number_socket +IntegerNumberSocketDef = integer_number_socket.IntegerNumberSocketDef + +from . import rational_number_socket +RationalNumberSocketDef = rational_number_socket.RationalNumberSocketDef + from . import real_number_socket RealNumberSocketDef = real_number_socket.RealNumberSocketDef @@ -6,6 +12,8 @@ ComplexNumberSocketDef = complex_number_socket.ComplexNumberSocketDef BL_REGISTER = [ + *integer_number_socket.BL_REGISTER, + *rational_number_socket.BL_REGISTER, *real_number_socket.BL_REGISTER, *complex_number_socket.BL_REGISTER, ] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/complex_number_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/complex_number_socket.py index 8e4c7bc..e5f466c 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/complex_number_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/complex_number_socket.py @@ -12,15 +12,13 @@ from ... import contracts #################### class ComplexNumberBLSocket(base.BLSocket): socket_type = contracts.SocketType.ComplexNumber - socket_color = (0.6, 0.6, 0.6, 1.0) - bl_label = "Complex Number" compatible_types = { complex: {}, sp.Expr: { - lambda v: v.is_complex, - lambda v: len(v.free_symbols) == 0, + lambda self, v: v.is_complex, + lambda self, v: len(v.free_symbols) == 0, }, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/integer_number_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/integer_number_socket.py new file mode 100644 index 0000000..4357514 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/integer_number_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class IntegerNumberBLSocket(base.BLSocket): + socket_type = contracts.SocketType.IntegerNumber + bl_label = "IntegerNumber" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class IntegerNumberSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.IntegerNumber + label: str + + def init(self, bl_socket: IntegerNumberBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + IntegerNumberBLSocket +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/rational_number_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/rational_number_socket.py index e69de29..fb39775 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/rational_number_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/rational_number_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class RationalNumberBLSocket(base.BLSocket): + socket_type = contracts.SocketType.RationalNumber + bl_label = "Rational Number" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class RationalNumberSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.RationalNumber + label: str + + def init(self, bl_socket: RationalNumberBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + RationalNumberBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/real_number_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/real_number_socket.py index 09bafbf..d7427fe 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/real_number_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/number/real_number_socket.py @@ -12,15 +12,13 @@ from ... import contracts #################### class RealNumberBLSocket(base.BLSocket): socket_type = contracts.SocketType.RealNumber - socket_color = (0.6, 0.6, 0.6, 1.0) - bl_label = "Real Number" compatible_types = { float: {}, sp.Expr: { - lambda v: v.is_real, - lambda v: len(v.free_symbols) == 0, + lambda self, v: v.is_real, + lambda self, v: len(v.free_symbols) == 0, }, } diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/__init__.py index ade66a6..943e06e 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/__init__.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/__init__.py @@ -1,7 +1,56 @@ -from . import physical_area_socket -PhysicalAreaSocketDef = physical_area_socket.PhysicalAreaSocketDef +from . import time_socket +PhysicalTimeSocketDef = time_socket.PhysicalTimeSocketDef + +from . import angle_socket +PhysicalAngleSocketDef = angle_socket.PhysicalAngleSocketDef + +from . import length_socket +from . import area_socket +from . import volume_socket +PhysicalLengthSocketDef = length_socket.PhysicalLengthSocketDef +PhysicalAreaSocketDef = area_socket.PhysicalAreaSocketDef +PhysicalVolumeSocketDef = volume_socket.PhysicalVolumeSocketDef + +from . import mass_socket +PhysicalMassSocketDef = mass_socket.PhysicalMassSocketDef + +from . import speed_socket +from . import accel_socket +from . import force_socket +PhysicalSpeedSocketDef = speed_socket.PhysicalSpeedSocketDef +PhysicalAccelSocketDef = accel_socket.PhysicalAccelSocketDef +PhysicalForceSocketDef = force_socket.PhysicalForceSocketDef + +from . import pol_socket +PhysicalPolSocketDef = pol_socket.PhysicalPolSocketDef + +from . import freq_socket +PhysicalFreqSocketDef = freq_socket.PhysicalFreqSocketDef + +from . import spec_rel_permit_dist_socket +from . import spec_power_dist_socket +PhysicalSpecRelPermDistSocketDef = spec_rel_permit_dist_socket.PhysicalSpecRelPermDistSocketDef +PhysicalSpecPowerDistSocketDef = spec_power_dist_socket.PhysicalSpecPowerDistSocketDef BL_REGISTER = [ - *physical_area_socket.BL_REGISTER, + *time_socket.BL_REGISTER, + + *angle_socket.BL_REGISTER, + + *length_socket.BL_REGISTER, + *area_socket.BL_REGISTER, + *volume_socket.BL_REGISTER, + + *mass_socket.BL_REGISTER, + + *speed_socket.BL_REGISTER, + *accel_socket.BL_REGISTER, + *force_socket.BL_REGISTER, + + *pol_socket.BL_REGISTER, + + *freq_socket.BL_REGISTER, + *spec_rel_permit_dist_socket.BL_REGISTER, + *spec_power_dist_socket.BL_REGISTER, ] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/accel_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/accel_socket.py new file mode 100644 index 0000000..c2d5d83 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/accel_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalAccelBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalAccel + bl_label = "PhysicalAccel" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalAccelSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalAccel + label: str + + def init(self, bl_socket: PhysicalAccelBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalAccelBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/angle_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/angle_socket.py new file mode 100644 index 0000000..3a2b62d --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/angle_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalAngleBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalAngle + bl_label = "PhysicalAngle" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalAngleSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalAngle + label: str + + def init(self, bl_socket: PhysicalAngleBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalAngleBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_area_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/area_socket.py similarity index 52% rename from blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_area_socket.py rename to blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/area_socket.py index cbac4a3..5adf794 100644 --- a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_area_socket.py +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/area_socket.py @@ -5,36 +5,21 @@ import sympy as sp import sympy.physics.units as spu import pydantic as pyd -sp.printing.str.StrPrinter._default_settings['abbrev'] = True -## When we str() a unit expression, use abbrevied units. - from .. import base from ... import contracts -UNITS = { - "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, -} -DEFAULT_UNIT = "UM_SQ" - class PhysicalAreaBLSocket(base.BLSocket): socket_type = contracts.SocketType.PhysicalArea - socket_color = (0.8, 0.5, 0.5, 1.0) - bl_label = "Physical Area" + use_units = True compatible_types = { sp.Expr: { - lambda v: v.is_real, - lambda v: len(v.free_symbols) == 0, - lambda v: any( + lambda self, v: v.is_real, + lambda self, v: len(v.free_symbols) == 0, + lambda self, v: any( contracts.is_exactly_expressed_as_unit(v, unit) - for unit in UNITS.values() + for unit in self.units.values() ) }, } @@ -48,17 +33,6 @@ class PhysicalAreaBLSocket(base.BLSocket): default=0.0, precision=6, ) - unit: bpy.props.EnumProperty( - name="Unit", - description="Choose between area units", - items=[ - (unit_name, str(unit_value), str(unit_value)) - for unit_name, unit_value in UNITS.items() - ], - default=DEFAULT_UNIT, - update=lambda self, context: self._update_unit(), - ) - unit_previous: bpy.props.StringProperty(default=DEFAULT_UNIT) #################### # - Socket UI @@ -68,13 +42,11 @@ class PhysicalAreaBLSocket(base.BLSocket): specifying the active unit. """ label_col_row.label(text=text) - #label_col_row.prop(self, "raw_value", text="") - label_col_row.prop(self, "unit", text="") + label_col_row.prop(self, "raw_unit", text="") def draw_value(self, col: bpy.types.UILayout) -> None: col_row = col.row(align=True) col_row.prop(self, "raw_value", text="") - #col_row.prop(self, "unit", text="") #################### # - Computation of Default Value @@ -88,7 +60,7 @@ class PhysicalAreaBLSocket(base.BLSocket): The area as a sympy expression (with units). """ - return self.raw_value * UNITS[self.unit] + return self.raw_value * self.unit @default_value.setter def default_value(self, value: typ.Any) -> None: @@ -97,27 +69,7 @@ class PhysicalAreaBLSocket(base.BLSocket): units. """ - # (Guard) Value Compatibility - if not self.is_compatible(value): - msg = f"Tried setting socket ({self}) to incompatible value ({value}) of type {type(value)}" - raise ValueError(msg) - - self.raw_value = spu.convert_to( - value, UNITS[self.unit] - ) / UNITS[self.unit] - - #################### - # - Internal Update Methods - #################### - def _update_unit(self): - old_unit = UNITS[self.unit_previous] - new_unit = UNITS[self.unit] - - self.raw_value = spu.convert_to( - self.raw_value * old_unit, - new_unit, - ) / new_unit - self.unit_previous = self.unit + self.raw_value = self.value_as_unit(value) #################### # - Socket Configuration @@ -126,18 +78,11 @@ class PhysicalAreaSocketDef(pyd.BaseModel): socket_type: contracts.SocketType = contracts.SocketType.PhysicalArea label: str - default_unit: typ.Literal[ - "PM_SQ", - "A_SQ", - "NM_SQ", - "UM_SQ", - "MM_SQ", - "CM_SQ", - "M_SQ", - ] + default_unit: typ.Any | None = None def init(self, bl_socket: PhysicalAreaBLSocket) -> None: - bl_socket.unit = self.default_unit + if self.default_unit: + bl_socket.unit = self.default_unit #################### # - Blender Registration diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/base.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/base.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/force_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/force_socket.py new file mode 100644 index 0000000..e558597 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/force_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalForceBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalForce + bl_label = "PhysicalForce" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalForceSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalForce + label: str + + def init(self, bl_socket: PhysicalForceBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalForceBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/freq_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/freq_socket.py new file mode 100644 index 0000000..66a1cb3 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/freq_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalFreqBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalFreq + bl_label = "PhysicalFreq" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalFreqSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalFreq + label: str + + def init(self, bl_socket: PhysicalFreqBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalFreqBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/length_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/length_socket.py new file mode 100644 index 0000000..d153d89 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/length_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalLengthBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalLength + bl_label = "PhysicalLength" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalLengthSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalLength + label: str + + def init(self, bl_socket: PhysicalLengthBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalLengthBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/mass_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/mass_socket.py new file mode 100644 index 0000000..f2a3619 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/mass_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalMassBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalMass + bl_label = "PhysicalMass" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalMassSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalMass + label: str + + def init(self, bl_socket: PhysicalMassBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalMassBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_length_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_length_socket.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_mass_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_mass_socket.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_speed_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_speed_socket.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_time_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/physical_time_socket.py deleted file mode 100644 index e69de29..0000000 diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/pol_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/pol_socket.py new file mode 100644 index 0000000..bec9d32 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/pol_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalPolBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalPol + bl_label = "PhysicalPol" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalPolSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalPol + label: str + + def init(self, bl_socket: PhysicalPolBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalPolBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_power_dist_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_power_dist_socket.py new file mode 100644 index 0000000..8285d7e --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_power_dist_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalSpecPowerDistBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalSpecPowerDist + bl_label = "PhysicalSpecPowerDist" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalSpecPowerDistSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalSpecPowerDist + label: str + + def init(self, bl_socket: PhysicalSpecPowerDistBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalSpecPowerDistBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_rel_permit_dist_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_rel_permit_dist_socket.py new file mode 100644 index 0000000..c54b26c --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/spec_rel_permit_dist_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalSpecRelPermDistBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalSpecRelPermDist + bl_label = "PhysicalSpecRelPermDist" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalSpecRelPermDistSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalSpecRelPermDist + label: str + + def init(self, bl_socket: PhysicalSpecRelPermDistBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalSpecRelPermDistBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/speed_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/speed_socket.py new file mode 100644 index 0000000..4d3e8fb --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/speed_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalSpeedBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalSpeed + bl_label = "PhysicalSpeed" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalSpeedSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalSpeed + label: str + + def init(self, bl_socket: PhysicalSpeedBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalSpeedBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/time_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/time_socket.py new file mode 100644 index 0000000..093ddbe --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/time_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class PhysicalTimeBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalTime + bl_label = "PhysicalTime" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class PhysicalTimeSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalTime + label: str + + def init(self, bl_socket: PhysicalTimeBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalTimeBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/volume_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/volume_socket.py new file mode 100644 index 0000000..4fa88fc --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/physical/volume_socket.py @@ -0,0 +1,97 @@ +import typing as typ + +import bpy +import sympy as sp +import sympy.physics.units as spu +import pydantic as pyd + +sp.printing.str.StrPrinter._default_settings['abbrev'] = True +## When we str() a unit expression, use abbrevied units. + +from .. import base +from ... import contracts + +class PhysicalVolumeBLSocket(base.BLSocket): + socket_type = contracts.SocketType.PhysicalVolume + bl_label = "Physical Volume" + use_units = True + + compatible_types = { + sp.Expr: { + lambda self, v: v.is_real, + lambda self, v: len(v.free_symbols) == 0, + lambda self, v: any( + contracts.is_exactly_expressed_as_unit(v, unit) + for unit in self.units.values() + ) + }, + } + + #################### + # - Properties + #################### + raw_value: bpy.props.FloatProperty( + name="Unitless Volume", + description="Represents the unitless part of the area", + default=0.0, + precision=6, + ) + + #################### + # - Socket UI + #################### + def draw_label_row(self, label_col_row: bpy.types.UILayout, text: str) -> None: + """Draw the value of the area, including a toggle for + specifying the active unit. + """ + label_col_row.label(text=text) + #label_col_row.prop(self, "raw_value", text="") + label_col_row.prop(self, "raw_unit", text="") + + def draw_value(self, col: bpy.types.UILayout) -> None: + col_row = col.row(align=True) + col_row.prop(self, "raw_value", text="") + #col_row.prop(self, "unit", text="") + + #################### + # - Computation of Default Value + #################### + @property + def default_value(self) -> sp.Expr: + """Return the area as a sympy expression, which is a pure real + number perfectly expressed as the active unit. + + Returns: + The area as a sympy expression (with units). + """ + + return self.raw_value * self.unit + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + """Set the area from a sympy expression, including any required + unit conversions to normalize the input value to the selected + units. + """ + + self.raw_value = self.value_as_unit(value) + +#################### +# - Socket Configuration +#################### +class PhysicalVolumeSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.PhysicalVolume + label: str + + default_unit: typ.Any | None = None + + def init(self, bl_socket: PhysicalVolumeBLSocket) -> None: + if self.default_unit: + bl_socket.unit = self.default_unit + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + PhysicalVolumeBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/__init__.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/__init__.py new file mode 100644 index 0000000..1b718ad --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/__init__.py @@ -0,0 +1,18 @@ +from . import real_2d_vector_socket +from . import complex_2d_vector_socket +Real2DVectorSocketDef = real_2d_vector_socket.Real2DVectorSocketDef +Complex2DVectorSocketDef = complex_2d_vector_socket.Complex2DVectorSocketDef + +from . import real_3d_vector_socket +from . import complex_3d_vector_socket +Real3DVectorSocketDef = real_3d_vector_socket.Real3DVectorSocketDef +Complex3DVectorSocketDef = complex_3d_vector_socket.Complex3DVectorSocketDef + + +BL_REGISTER = [ + *real_2d_vector_socket.BL_REGISTER, + *complex_2d_vector_socket.BL_REGISTER, + + *real_3d_vector_socket.BL_REGISTER, + *complex_3d_vector_socket.BL_REGISTER, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_2d_vector_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_2d_vector_socket.py new file mode 100644 index 0000000..537d6e4 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_2d_vector_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class Complex2DVectorBLSocket(base.BLSocket): + socket_type = contracts.SocketType.Complex2DVector + bl_label = "Complex2DVector" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class Complex2DVectorSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.Complex2DVector + label: str + + def init(self, bl_socket: Complex2DVectorBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + Complex2DVectorBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_3d_vector_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_3d_vector_socket.py new file mode 100644 index 0000000..6d70e99 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/complex_3d_vector_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class Complex3DVectorBLSocket(base.BLSocket): + socket_type = contracts.SocketType.Complex3DVector + bl_label = "Complex3DVector" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class Complex3DVectorSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.Complex3DVector + label: str + + def init(self, bl_socket: Complex3DVectorBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + Complex3DVectorBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_2d_vector_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_2d_vector_socket.py new file mode 100644 index 0000000..708aadf --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_2d_vector_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class Real2DVectorBLSocket(base.BLSocket): + socket_type = contracts.SocketType.Real2DVector + bl_label = "Real2DVector" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class Real2DVectorSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.Real2DVector + label: str + + def init(self, bl_socket: Real2DVectorBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + Real2DVectorBLSocket, +] diff --git a/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_3d_vector_socket.py b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_3d_vector_socket.py new file mode 100644 index 0000000..b43e490 --- /dev/null +++ b/blender_maxwell/node_trees/maxwell_sim_nodes/sockets/vector/real_3d_vector_socket.py @@ -0,0 +1,41 @@ +import typing as typ + +import pydantic as pyd + +from .. import base +from ... import contracts + +#################### +# - Blender Socket +#################### +class Real3DVectorBLSocket(base.BLSocket): + socket_type = contracts.SocketType.Real3DVector + bl_label = "Real3DVector" + + #################### + # - Default Value + #################### + @property + def default_value(self) -> None: + pass + + @default_value.setter + def default_value(self, value: typ.Any) -> None: + pass + +#################### +# - Socket Configuration +#################### +class Real3DVectorSocketDef(pyd.BaseModel): + socket_type: contracts.SocketType = contracts.SocketType.Real3DVector + label: str + + def init(self, bl_socket: Real3DVectorBLSocket) -> None: + pass + +#################### +# - Blender Registration +#################### +BL_REGISTER = [ + Real3DVectorBLSocket, +] diff --git a/blender_maxwell/utils/blender_type_enum.py b/blender_maxwell/utils/blender_type_enum.py index 17196ea..253791e 100644 --- a/blender_maxwell/utils/blender_type_enum.py +++ b/blender_maxwell/utils/blender_type_enum.py @@ -14,3 +14,15 @@ def append_cls_name_to_values(cls): # Return New (Replacing) Enum Class return new_cls + +def wrap_values_in_MT(cls): + # Construct Set w/Modified Member Names + new_members = {name: f"BLENDER_MAXWELL_MT_{name}" for name, member in cls.__members__.items()} + + # Dynamically Declare New Enum Class w/Modified Members + new_cls = enum.Enum(cls.__name__, new_members, type=BlenderTypeEnum) + new_cls.__module__ = cls.__module__ + new_cls.get_tree = cls.get_tree ## TODO: This is wildly specific... + + # Return New (Replacing) Enum Class + return new_cls