Exemplo n.º 1
0
def make_xou_source(clock_angle, wave, N, source_dist):
    prays = source.subannulus(700, 740, 0.10, N, zhat=-1.)
    tran.transform(prays, 0., 0., 0., 0., 0., clock_angle - pi / 2)
    tran.pointTo(prays, 0., mean([705, 745]), source_dist, reverse=1)
    if type(wave) == float:
        wavedist = zeros(N) + wave
    else:
        wavedist = wave.draw_waves(N)
    xou_rays = ArcRays.ArcusRays(prays, wavedist)
    return xou_rays
Exemplo n.º 2
0
def traceZeta(pmin,R0=220.,Z0=1e4,psi=1.,offaxis=0.,L=200.,az=100.,pause=False):
    """
    Set initial aperture based on height of bottom of mirror
    above node (pmin). Assume 100 mm long mirrors.
    Then, trace to secondary and mark smin and smax for
    where the rays strike.
    Then trace out off axis field positions and determine
    RMS and HPD vs angle.
    """
    #Set up aperture
    a0 = wsPrimrad(pmin,R0,Z0,psi)
    a1 = wsPrimrad(pmin+L,R0,Z0,psi) 
    rays = sources.subannulus(a0,a1,az/R0,1e4)
    tran.transform(rays,0,0,-Z0,0,0,0)

    #Trace to primary and add off-axis angle
    surf.wsPrimary(rays,R0,Z0,psi)
    rays[4] = rays[4]+np.sin(offaxis)
    rays[6] = -np.sqrt(1.-rays[4]**2)
    tran.reflect(rays)

    #Trace to secondary
    surf.wsSecondary(rays,R0,Z0,psi)
    tran.reflect(rays)
    smax = np.nanmax(rays[3])
    smin = np.nanmin(rays[3])
    if pause is True:
        pdb.set_trace()

    #Go to focus
    f = surf.focusI(rays)

    #Compute merit functions
    hpd = anal.hpd(rays)
    rms = anal.rmsCentroid(rays)

    return smin,smax,f,hpd,rms
periods1 = np.load('Probabilities_5.npy')
xs2 = np.load('positions_3.npy')
periods2 = np.load('Probabilities_3.npy')

# Define Wolter-I parameters.
r0 = 165.  # Radius at the intersection plane of primary/secondary.
z0 = 3500.  #
mirror_len = 100.
mirror_sep = 5.

# Define inner & outer radii to create rays.
rp_front = conic.primrad(z0 + mirror_sep / 2 + mirror_len, r0, z0)
rp_back = conic.primrad(z0 + mirror_sep / 2, r0, z0)

# Define initial rays in subannulus.
rays = sources.subannulus(rp_back, rp_front, np.radians(30.), 100000)

# Transform rays to intersection plane of optic.
trans.transform(rays, 0, 0, -z0, 0, 0, 0)

# Rotate 90 degrees so that diffraction occurs in x-axis.
trans.transform(rays, 0, 0, 0, 0, 0, -np.radians(90.))

# Pass through primary.
surfaces.wolterprimary(rays, r0, z0)
trans.reflect(rays)

# # Add some scatter.
ogre.beckmann_scatter(rays, 0, 0, 1.48e-5)

# Pass through secondary.
# We begin by defining some rays from a source at the end of the test chamber.

# In[15]:

# Define inner and outer subannulus radii.
z_in = z0 + mirror_sep / 2
z_out = z_in + mirror_len

r_in = conic.primrad(z_in, r0, z0)
r_out = conic.primrad(z_out, r0, z0)

# Define full angular width of subannulus.
dphi = np.radians(30.)

# # Define subannulus of rays.
rays = sources.subannulus(r_in, r_out, dphi, 1000000)

# rays = np.loadtxt('rays.txt')

# Rotate so that dispersion direction is in the x-dimension.
trans.transform(rays, 0, 0, 0, 0, 0, -np.pi / 2)

# Find centroid of rays and move rays down to center of beamline.
cen_optic = analyses.centroid(rays)

trans.transform(rays, 0, cen_optic[1], 0, 0, 0, 0)
trans.transform(rays, 0, -30, 0, 0, 0, 0)

# Change ray direction cosines to emanate from source (48 m away).
hyp = np.sqrt(L**2 + rays[1]**2 + rays[2]**2)
l = rays[1] / hyp