Пример #1
0
    def setUp(self):
        self.wp = Waveplate(direction=(0.,0.,1.))
        self.src = ParallelRaySource(rings=0,
                                     E_vector=(1,0,0),
                                     E1_amp = 1.0+0.0j,
                                     E2_amp = 0.0+0.0j,
                                     direction = (0,0,1),
                                     origin = (0,0,-10),
                                    )

        self.model = RayTraceModel(optics=[self.wp,],
                                   sources=[self.src])
Пример #2
0
    def test_quarter_retardance2(self):
        src = SingleRaySource(E_vector=(1,0,0),
                                 E1_amp = 1.0+0.0j,
                                 E2_amp = 0.0+0.0j,
                                 direction = (0,0,1),
                                 origin = (0,0,-40),
                                )

        wp1 = Waveplate(retardance=0.25,
                       rotation = 45.0,
                       centre=(0,0,40),
                       direction=(0,0,1))

        print("wp1 fa:", wp1.material.fast_axis)

        wp2 = Waveplate(retardance=0.25,
                       rotation = -45.0,
                       centre=(0,0,80),
                       direction=(0,0,-1))

        print("wp2 fa:", wp2.material.fast_axis)
        print("wp1 fa:", wp1.material.fast_axis)

        model = RayTraceModel(optics=[wp1,wp2], sources=[src])
        model.trace_all()

        def get_major_axis(ray):
            E1_vector = numpy.array(ray.E_vector)
            E2_vector = numpy.cross(numpy.array(ray.direction),
                                    E1_vector)
            E = (E1_vector*ray.E1_amp + E2_vector*ray.E2_amp)
            return E.real

        ray_in = src.InputRays[0]

        #print ray_in.E_vector, ray_in.E1_amp, ray_in.E2_amp

        self.assertEqual(len(src.TracedRays), 3)

        for i in range(len(src.TracedRays)):
            ray = src.TracedRays[i][0]
            print(i, "::", get_major_axis(ray), ray.E_left, ray.E_right, ray.ellipticity, ray.E_vector)
Пример #3
0
    def test_quarter_retardance(self):
        src = SingleRaySource(E_vector=(1,0,0),
                                 E1_amp = 1.0+0.0j,
                                 E2_amp = 0.0+0.0j,
                                 direction = (0,0,1),
                                 origin = (0,0,-40),
                                )

        wp = Waveplate(retardance=0.25,
                       rotation = 45.0,
                       centre=(0,0,40),
                       direction=(0,0,1))

        m = PECMirror(centre=(0,0,80),
                      direction=(0.0,0.0,1.0))

        model = RayTraceModel(optics=[wp,m], sources=[src])
        #model.trace_all()

        def get_major_axis(ray):
            E1_vector = numpy.array(ray.E_vector)
            E2_vector = numpy.cross(numpy.array(ray.direction),E1_vector
                                    )
            E = (E1_vector*ray.E1_amp + E2_vector*ray.E2_amp)
            return E

        ray_in = src.InputRays[0]

        #print ray_in.E_vector, ray_in.E1_amp, ray_in.E2_amp

        self.assertEqual(len(src.TracedRays), 4)

        for i in range(4):
            ray = src.TracedRays[i][0]
            print(i, "::", ray.E_left, ray.E_right, ray.E_vector, ray.E1_amp, ray.E2_amp)
            print("\t", get_major_axis(ray))

        ray_out = src.TracedRays[-1][0]
        self.assertAlmostEqual(numpy.dot(get_major_axis(ray_out),
                                    get_major_axis(ray_in)), 0.0)
sys.path.append('..')
import pyximport
pyximport.install()

from raytrace.tracer import RayTraceModel
from raytrace.sources import BroadbandRaySource
from raytrace.diffraction_gratings import RectangularGrating

source = BroadbandRaySource(number=5,
                            wavelength_start=1.5,
                            wavelength_end=1.6,
                            uniform_deltaf=True,
                            origin=(-50, 0, 0),
                            direction=(1., 0, 0))

grating = RectangularGrating(length=25.4,
                             width=25.4,
                             thickness=6.0,
                             centre=(0.0, 0.0, 0.0),
                             direction=(-1, 0, 0),
                             lines_per_mm=600,
                             efficiency=1.0,
                             order=1)

rays = source.InputRays

model = RayTraceModel(optics=[grating], sources=[
    source,
])

model.configure_traits()
Пример #5
0
D2 = np.dot(rot_matrix,D2)-trans_vector
c21 = np.dot(rot_matrix,c21)-trans_vector
c22 = np.dot(rot_matrix,c22)-trans_vector
E2 = np.dot(rot_matrix,E2)-trans_vector

left_arm = Extruded_bezier(name = "left arm",control_points = np.array([[D2,c21,c22,E2]]),z_height_1 = 0, z_height_2 = system_length, material = PECMaterial())



target = RectTarget(width = len_exit_ap, length = system_length, elevation=90., rotation =90., centre = (0,0,system_length/2.))

source = RectRaySource(origin=(0,100,system_length/4.),
                            direction=(0,-1,0),
                            working_dist = 200.,
                            number=10,
                            length = system_length/4.,
            			    width = 10,   #lea+2*E[0],
            			    randomness = True,
                            theta = 10.00000001)

raypaths = RayPaths()

model = RayTraceModel(sources=[source],
                      optics=[target, right_arm,left_arm], results = [raypaths], recursion_limit=10)


model.configure_traits()


            profile[len(profile):] = xtr_pts

        self.profile = profile
#print profile


#polygon approximation of parabolic trough mirror
para = approx_parabola(material=PECMaterial(),
                       z_height_1=-20.0,
                       z_height_2=20.0,
                       focal_length=10)

print(0)
model0 = RayTraceModel(optics=[
    para,
], sources=[
    source,
])
print(1)
model1 = RayTraceModel(optics=[
    para,
], sources=[
    source,
])
print(2)
model2 = RayTraceModel(optics=[
    para,
], sources=[
    source,
])
print(3)
Пример #7
0
    randomness=True)
#linear dialectric filled light funnel
r1 = LDLF(  #material=OpaqueMaterial(),
    z_height_1=-20.0,
    z_height_2=20.0,
    slat_width=slat_width,
    ap_width=ex_ap,
    slant=slant,
    n_inside=1.333)  #1.333 = water

ratio = Ratio(denominator=r1.faces[2], nominator=r1.faces[0])
raypaths = RayPaths()

model = RayTraceModel(optics=[
    r1,
],
                      sources=[s1, s2, s3, s4, s5],
                      results=[ratio, raypaths],
                      recursion_limit=5)

entry_ap = r1.faces.faces[2]
newsource = trace_pretty(model, 1, [entry_ap])

model.sources = [
    newsource,
]
#model.configure_traits()
#print model.all_faces

#ap_ratio = ent_ap/ex_ap
#print "ap ratio: ", ap_ratio
#print "effective concentration: ", ap_ratio*model.results[0].result	#still not right, circular source biases ratio.
Пример #8
0
from raytrace.tracer import RayTraceModel
from raytrace.parabolics import OffAxisParabloid
from raytrace.sources import ConfocalRaySource

h = 25.4

oap = OffAxisParabloid(diameter=50.4, height=h, EFL=50.4)

source = ConfocalRaySource(focus=(0, 0, 0),
                           direction=(1, 0, 0),
                           working_dist=10.0,
                           number=8,
                           rings=2,
                           theta=15.0,
                           export_pipes=True)

model = RayTraceModel(optics=[oap], sources=[source])

model.configure_traits()
Пример #9
0
  show_polarisation: false
  show_start: true
- !SolidRetroreflector
  __traits_version__: 3.3.0
  _orientation: !!python/tuple [0.0, 0.0]
  all_rays: false
  centre: !!python/tuple [0.0, 0.0, 0.0]
  diameter: 25.399999999999999
  direction: !!python/tuple [0.0, 0.0, 1.0]
  display: shaded
  elevation: 0.0
  material: !!python/object:raytrace.cmaterials.DielectricMaterial {}
  n_inside: !!python/complex '1.5'
  n_outside: !!python/complex '1.0'
  name: Solid Retroreflector
  orientation: 0.0
  rotation: 0.0
  thickness: 20.0
"""

import yaml

print(yaml.dump([source, cc]))

source, cc = yaml.load(data)

model = RayTraceModel(sources=[source], optics=[cc])

model.configure_traits()
#model.update = True
#print source.TracedRays
Пример #10
0
source = ParallelRaySource(
    origin=(0, 20, 0),
    direction=(0, -1, 1),
    working_dist=10.,
    #number=20,
    radius=1.)

#print source.InputDetailRays.origin.shape

m1 = TroughParabloid(width=20, length=100, EFL=5, centre=(0, 0, 0))

print(m1.intersect)

model = RayTraceModel(optics=[
    m1,
],
                      sources=[
                          source,
                      ],
                      probes=[],
                      recursion_limit=2)

#model.trace_detail_async()
#import time
#start = time.clock()
#model.trace_all()
#end = time.clock()
#print "traced in", end - start

model.configure_traits()
Пример #11
0
                           working_dist=100.,
                           number=4,
                           rings=1,
                           detail_resolution=5,
                           theta=10.)

w1 = PlanarWindow(diameter=25.4,
                  thickness=5.0,
                  centre=(0, -20, 0),
                  direction=(0, 1, 1),
                  n_inside=3.4,
                  name="w1")

model = RayTraceModel(optics=[
    w1,
], sources=[
    source,
])

#model.trace_detail_async()
#import time
#start = time.clock()
#model.trace_all()
#end = time.clock()
#print "traced in", end - start

#import timeit
#t = timeit.Timer("model.update = True","from __main__ import model")
#ret = t.timeit(10)
#print "time:", ret
Пример #12
0
from raytrace.results import Ratio

import numpy

source = ConfocalRaySource(focus=(0,0,0),
                            direction=(0,1,0),
                            working_dist = 100.,
                            number=20,
                            detail_resolution=5,
                            theta=10.)

#print source.InputDetailRays.origin.shape
                            
m1 = PECMirror(name="M1",
                centre=(0,-40,0),
                direction=(0,1,-1),
                diameter=30.,
                thickness=5.)               
    
                
l1 = PlanoConvexLens(centre=(0,-40,30),
                direction=(0,0,1))

ratio = Ratio(denominator=m1.faces[0],
              nominator=l1.faces[1])
                
model = RayTraceModel(optics=[m1,l1],
                    sources=[source,],
                    results=[ratio])               

model.configure_traits()
Пример #13
0
source = RectRaySource(origin=(10, 30, 0),
                       direction=(.1, -1, 0),
                       working_dist=100.,
                       number=1,
                       length=0,
                       width=0,
                       randomness=False,
                       scale_factor=0.2)
'''

source = RectRaySource(origin=(10.,10.,0),
                            direction=(.2,-1,0),
                            working_dist = 100.,
                            number=3,
                            length = 12,
            			    width = 12,
            			    randomness = False,
                            scale_factor=0.2)
'''
raypaths = RayPaths()

model = RayTraceModel(sources=[source],
                      optics=[test],
                      results=[raypaths],
                      recursion_limit=10)

#test.invert_normal = True
hits = model.sources[0].TracedRays
res = model.results[0].result
model.configure_traits()
Пример #14
0
                
e1 = Ellipsoid(focus1=(0,-40,40),
                focus2=(0,0,80),
                size=80,
                X_bounds=(-30,0),
                Y_bounds=(-15,15),
                Z_bounds=(40-15.,40+15.))
                
e2 = Ellipsoid(focus1=(0,40,40),
                focus2=(0,0,80),
                size=80,
                X_bounds=(0,30),
                Y_bounds=(-15,15),
                Z_bounds=(40-15.,40+15.))      
                
l1 = PlanoConvexLens(centre=(0,-40,30),
                direction=(0,0,1))
                
model = RayTraceModel(optics=[m1,m2,m3,m4,m5,e1,e2, l1],
                    sources=[source,],
                    probes=[p1,])
 
#model.trace_detail_async()
#import time
#start = time.clock()
#model.trace_all()
#end = time.clock()
#print "traced in", end - start                   

model.configure_traits()
Пример #15
0
from raytrace.tracer import RayTraceModel
from raytrace.lenses import PlanoConvexLens
from raytrace.sources import ConfocalRaySource

lens = PlanoConvexLens(centre=(20, 0, 0),
                       direction=(1, 0, 0),
                       curvature=25.0,
                       diameter=25.4,
                       CT=6.0)

source = ConfocalRaySource(focus=(0, 0, 0),
                           direction=(1, 0, 0),
                           working_dist=100.0,
                           theta=15.0)

model = RayTraceModel(optics=[lens], sources=[source])

model.configure_traits()
#try to make s as small as possible without making too many faces. (20 faces isn't unreasonable)

test = Extruded_interpolant(profile = [xs,ys], smoothness = 0, z_height_1 = -30, z_height_2=30, \
		material = DielectricMaterial(), n_inside=1.5, trace_ends= True,trace_top = False )

source = RectRaySource(origin=(50,0,0),
                            direction=(-1,0,0),
                            working_dist = 100.,
                            number=10,
                            length = 10,
			    width = 10,
			    randomness = True,
                            theta = 5.,
                            scale_factor=0.2)

'''
r1 = LDLF(material=PECMaterial(),
                z_height_1=-20.0,
                z_height_2=20.0,
                slat_width=20,
                ap_width=5,
                slant=75,
                n_inside=1.7)
'''


model = RayTraceModel(sources=[source],
                      optics=[test])
model.configure_traits()

Пример #17
0
for i, center in enumerate(centers):

    Mirrors[i] = RectMirror(width=mirror_width,
                            length=300.,
                            direction=(center, numpy.tan(-phi[i]) * center, 0),
                            centre=(center, 0, 0))

Optics = Mirrors

sorber = RectAbsorber(width=mirror_width,
                      length=300.,
                      direction=(0, -1, 0),
                      centre=(0, tower_height, 0))
Optics.append(sorber)

model = RayTraceModel(
    sources=[
        sun,
    ],
    optics=Optics,
)

#model.trace_detail_async()
#import time
#start = time.clock()
#model.trace_all()
#end = time.clock()
#print "traced in", end - start

model.configure_traits()
Пример #18
0
              y1=height_offset,
              x2=-ent_ap / 2,
              y2=height_offset,
              z_height_1=0,
              z_height_2=30,
              material=TransparentMaterial())

exit_ap = Sheet(x1=ex_ap / 2,
                y1=0,
                x2=-ex_ap / 2,
                y2=0,
                z_height_1=0,
                z_height_2=30,
                material=TransparentMaterial())

ratio = Ratio(denominator=en_ap.faces[0], nominator=exit_ap.faces[0])

model = RayTraceModel(optics=[r1, r2, en_ap, exit_ap],
                      sources=[
                          source,
                      ],
                      results=[ratio])

model.configure_traits()

print(model.all_faces)
ap_ratio = ent_ap / ex_ap
print("ap ratio: ", ap_ratio)
print("effective concentration: ", ap_ratio *
      model.results[0].result)  #still not right, circular source biases ratio.
Пример #19
0
                            #number=20,
                            radius=14.)
"""                            
s2 = ParallelRaySource(origin=(x,y,z),
                            direction=(xd,yd,zd),
                            working_dist = 50.,
                            #number=20,
                            radius=0)
"""                            
#print source.InputDetailRays.origin.shape
                            
m1 = CylindricalInvolute(width = 60,
                       length = 500,
                       tube_radius = 5,
                       begin_angle = -90.,
                       end_angle = 500.)
                
                
model = RayTraceModel(optics=[m1,],
                    sources=[s1,],
                    probes=[])
 
#model.trace_detail_async()
#import time
#start = time.clock()
#model.trace_all()
#end = time.clock()
#print "traced in", end - start                   

model.configure_traits()
Пример #20
0
from raytrace.tracer import RayTraceModel

model = RayTraceModel()

model.configure_traits()
Пример #21
0
#print source.InputDetailRays.origin.shape
                            
m1 = PECMirror(name="M1",
                centre=(0,-40,0),
                direction=(0,1,-1),
                diameter=30.,
                thickness=5.)
                
aligned = RectAperture(name="entry",
                    centre = (0,5,15),
                    direction = (0,1,0),
                    length = 30.,
                    width = 30.)
                    
antialigned = RectAperture(name="reversed",
                    centre = (0,-5,15),
                    direction = (0,-1,0),
                    length = 30.,
                    width = 30.)
                
l1 = PlanoConvexLens(centre=(0,-40,30),
                direction=(0,0,1))
                
ratio = Total_Efficency(Target=m1.faces[0],
              Aperture=aligned.faces[0])

model = RayTraceModel(optics=[m1,aligned,antialigned],
                    sources=[source,],
                    results=[ratio])               

model.configure_traits()
Пример #22
0
    z_height_1=-20.0,
    z_height_2=20.0,
    slat_width=5.0,  #
    ap_width=3.0,
    slant=80.0,
    n_inside=3)  #1.5 = glass, 3 = something crazy


class Ap_match_Constraint(BaseConstraint):
    r1 = Instance(LDLF, ())
    r2 = Instance(LDLF, ())

    @on_trait_change("r1.update")
    def calc_r2_param(self):
        h = self.r1.slat_width / numpy.sin(self.r1.slant * numpy.pi / 180.)
        self.r2.centre = (0, h, 0)
        x = self.r1.ap_width + 2 * self.r1.slat_width * numpy.cos(
            self.r1.slant * numpy.pi / 180.)
        self.r2.ap_width = x


c = Ap_match_Constraint(r1=r1, r2=r2)

model = RayTraceModel(optics=[r1, r2], constraints=[
    c,
], sources=[
    source,
])

model.configure_traits()