Skip to content

Coarse roughness at exit #106

@AnnieStephenson

Description

@AnnieStephenson

Course roughness at exit should be implemented. This may not have a large effect on overall reflectance but it will impact exit angle significantly, thus affecting goniometer detection results. Below is a start at implementing this exit coarse rougness. It has been commented out in detector.py for quite some time, and I've now removed it.

    # TODO For implementing coarse roughness when the trajectories exit the sample
    nev = z.shape[0]    
    # sample the surface roughness angles theta_a
    if coarse_roughness == 0.:
        theta_a = np.zeros(ntraj)
    else:
        theta_a_full = np.linspace(0.,np.pi/2, 500)
        prob_a = P_theta_a(theta_a_full,coarse_roughness)/sum(P_theta_a(theta_a_full,coarse_roughness))
        
        if np.isnan(prob_a).all(): 
            theta_a = np.zeros(ntraj)
        else: 
            theta_a = np.array([np.random.choice(theta_a_full, ntraj, p = prob_a) for i in range(1)]).flatten()
    
    # In case the surface is rough, then find new coordinates of initial 
    # directions after rotating the surface by an angle theta_a around y axis
    sintheta_a = np.tile(np.sin(theta_a), (nev, 1))
    costheta_a = np.tile(np.cos(theta_a), (nev, 1))
    
    kx_rot = costheta_a * kx - sintheta_a * kz
    ky_rot = ky.copy()
    kz_rot = sintheta_a * kx + costheta_a * kz

    # correct for non-TIR fresnel reflection upon exiting
    reflected = refl_weights * fresnel_pass_frac(kz_rot, refl_indices, n_sample, n_front, n_medium)#<= uncomment
    transmitted = trans_weights * fresnel_pass_frac(kz_rot, trans_indices, n_sample, n_back, n_medium)
------------------------------------------------------------------------------
    # For implementing coarse roughness when the trajectories exit the sample
    #trans_detected = detect_correct(kz_rot, transmitted, trans_indices, n_sample, n_medium, detection_angle)
    #refl_detected = detect_correct(kz_rot, reflected, refl_indices, n_sample, n_medium, detection_angle)
#------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions