コード例 #1
0
source = sources.PointSource(
    2, (0, -4.02), .7, angles, [drawing.YELLOW], rank_type=None
)"""
sample_count = 100
angles = distributions.RandomLambertianAngularDistribution(
    -.4 * PI, .4 * PI, sample_count)
beam_points = distributions.RandomUniformBeam(-.09, .09, sample_count)
source = sources.AngularSource(2, (0, -4.001),
                               PI / 2,
                               angles,
                               beam_points, [drawing.YELLOW] * sample_count,
                               rank_type=None,
                               dense=False)

# build the system
system = eng.OpticalSystem2D()
system.optical_segments = [boundary]
system.sources = [source]
system.materials = [{"n": materials.vacuum}, {"n": materials.acrylic}]

trace_engine = eng.OpticalEngine(2, [op.StandardReaction()],
                                 compile_dead_rays=True,
                                 dead_ray_length=10,
                                 simple_ray_inheritance={"wavelength"})
trace_engine.optical_system = system
system.update()
trace_engine.validate_system()
trace_engine.ray_trace(max_iterations=50)

# set up drawers
segment_drawer = drawing.SegmentDrawer(ax,
コード例 #2
0
        (1.0, -1.0), (1.0, 1.0), point_count
    )
    boundary = boundaries.ParametricMultiSegmentBoundary(
        zero_points,
        one_points,
        constraints=[
            boundaries.ThicknessConstraint(0.0, "min"),
            boundaries.ThicknessConstraint(0.5, "min"),
            boundaries.PointConstraint(0.0, 7, parent="zero")
            #boundaries.ThicknessConstraint(0.0, "min", parent="zero")
            #boundaries.PointConstraint(0.0, 0),
            #boundaries.PointConstraint(0.5, 7)
        ],
        flip_norm=[False, True, True]
    )
    system = engine.OpticalSystem2D()
    system.optical_segments = boundary.surfaces
    system.update()

    # set up drawer
    drawer = drawing.SegmentDrawer(ax, color="cyan", draw_norm_arrows=True)
    drawer.segments = system.optical_segments
    drawer.draw()

    # hand over to user
    fig.canvas.mpl_connect(
        "key_press_event",
        lambda event: on_key(event, drawer, boundary, system),
    )
    plt.show()