Skip to content

Commit

Permalink
total R/T/layer and interface A working for top incidence
Browse files Browse the repository at this point in the history
  • Loading branch information
phoebe-p committed Jul 17, 2024
1 parent 86d5175 commit e3e1a58
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 228 deletions.
22 changes: 15 additions & 7 deletions rayflare/ray_tracing/analytical_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def analytical_start(nks,
# if the surface is planar, can just use TMM or Fresnel equations directly
# should already have a lookuptable, if necessary

theta_t = np.real(np.arcsin(np.real(n0) / n1 * np.sin(angles.data)))
theta_t = np.arcsin(n0) / n1 * np.sin(angles.data)

Check warning on line 223 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L223

Added line #L223 was not covered by tests

x = np.sin(theta_t) * np.cos(phi)
y = np.sin(theta_t) * np.sin(phi)
Expand All @@ -231,7 +231,7 @@ def analytical_start(nks,
y = np.abs(y) * np.sign(d[1])
z = np.abs(z) * np.sign(d[2])

Check warning on line 232 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L230-L232

Added lines #L230 - L232 were not covered by tests

final_T_directions = xr.DataArray(np.stack((x, y, z))[None, :, :],
final_T_directions = xr.DataArray(np.real(np.stack((x, y, z)))[None, :, :],

Check warning on line 234 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L234

Added line #L234 was not covered by tests
dims=["face", "xyz", "wl"])

theta_t = xr.DataArray(theta_t[None, :], dims=["face", "wl"])

Check warning on line 237 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L237

Added line #L237 was not covered by tests
Expand Down Expand Up @@ -391,14 +391,19 @@ def analytical_start(nks,

prop_rays = []

Check warning on line 392 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L392

Added line #L392 was not covered by tests

# TODO: could have rays continuing to propagate in multiple materials (e.g. if you
# had multiple planar layers at the top of the structure). Currently cannot account
# for that

if include_R:

Check warning on line 398 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L398

Added line #L398 was not covered by tests

# TODO: add n_interactions

prop_rays.append(xr.Dataset(

Check warning on line 402 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L402

Added line #L402 was not covered by tests
{
"I": R_data.R_total.rename({"face": "unique_direction"}),
"direction": R_data.final_R_directions.rename({"face": "unique_direction"})
"direction": R_data.final_R_directions.rename({"face": "unique_direction"}),
"mat_i": mat_i - initial_dir,
}
)
)
Expand All @@ -408,7 +413,8 @@ def analytical_start(nks,
prop_rays.append(xr.Dataset(

Check warning on line 413 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L411-L413

Added lines #L411 - L413 were not covered by tests
{
"I": remaining_after_bulk.rename({"outgoing": "unique_direction"}),
"direction": T_data.final_T_directions.rename({"outgoing": "unique_direction"})
"direction": T_data.final_T_directions.rename({"outgoing": "unique_direction"}),
"mat_i": mat_i,
}
)
)
Expand All @@ -417,7 +423,7 @@ def analytical_start(nks,

prop_rays = xr.concat(prop_rays, dim="unique_direction")

Check warning on line 424 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L424

Added line #L424 was not covered by tests

return profile, A_per_layer, A_per_interface, overall_R, overall_T, prop_rays
return profile.T, A_per_layer.T, A_per_interface, overall_R, overall_T, prop_rays

Check warning on line 426 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L426

Added line #L426 was not covered by tests


else:
Expand All @@ -430,7 +436,7 @@ def analytical_start(nks,
# - interface absorption
# - bulk absorption
# - reflection
I_new = I_rem_data - np.sum(R_data.R_total, 0) - np.sum(A_per_layer, 0) - I_out_actual
I_new = I_rem_data - np.sum(R_data.R_total, 0) - np.sum(A_per_layer, 0)
I_remaining[0] = I_new

Check warning on line 440 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L439-L440

Added lines #L439 - L440 were not covered by tests
# TODO: I think this only works for downwards

Expand Down Expand Up @@ -486,7 +492,7 @@ def analytical_per_face(current_surf,


# TODO: only correct for downwards
n0 = np.real(nks[surf_index])
n0 = nks[surf_index]
n1 = nks[surf_index + direction]

Check warning on line 496 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L495-L496

Added lines #L495 - L496 were not covered by tests

opposite_faces = np.where(np.dot(normals, normals.T) < 0)[1]

Check warning on line 498 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L498

Added line #L498 was not covered by tests
Expand All @@ -506,6 +512,8 @@ def analytical_per_face(current_surf,

if len(r_in.flatten()) == 3:

Check warning on line 513 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L513

Added line #L513 was not covered by tests

# TODO: not sure if this is right for single d case

r_inc = np.tile(r_in, (how_many_faces, 1)) # (4, 3) array

Check warning on line 517 in rayflare/ray_tracing/analytical_rt.py

View check run for this annotation

Codecov / codecov/patch

rayflare/ray_tracing/analytical_rt.py#L517

Added line #L517 was not covered by tests
# r_inc = r_inc[:, :, None]

Expand Down
Loading

0 comments on commit e3e1a58

Please sign in to comment.