Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coarse roughness at exit #106

Open
AnnieStephenson opened this issue Mar 30, 2023 · 0 comments
Open

Coarse roughness at exit #106

AnnieStephenson opened this issue Mar 30, 2023 · 0 comments

Comments

@AnnieStephenson
Copy link
Collaborator

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)
#------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant