Skip to content

Commit

Permalink
more detailed outputs from rt_structure, doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
phoebe-p committed Sep 20, 2024
1 parent 99a77ad commit 6f0c955
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
5 changes: 5 additions & 0 deletions docs/Examples/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Examples
========
.. _examples:

In addition to the examples listed here, you can find further detailed examples which use both
RayFlare and Solcore (our integrated solar cell modelling package which also includes device physics
models) on the
[solcore-education](https://qpv-research-group.github.io/solcore-education/solcore-workshop-2/schedule.html) page.

Structures using a single simulation method per structure
----------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ optical models behind RayFlare, you can do that :ref:`here <overview>` or get st

Check the :ref:`news & updates page <news>` for recent changes and new functionality.

If you want to be notified about new releases, please join our `mailing list`_:.
If you want to be notified about new releases, please join our `mailing list`_: (this will be at most a few emails per year,
we will not spam you!).

If you use RayFlare in your work, please cite the `JOSS paper`_:

Expand Down
3 changes: 2 additions & 1 deletion docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ News & Updates
================
.. _news:

If you want to be notified about new releases, please join our [mailing list](https://www.solcore.solar/mailing-list).
If you want to be notified about new releases, please join our [mailing list](https://www.solcore.solar/mailing-list) --
we will send at most a few emails a year.

To update to the latest version of RayFlare, run the following command in your terminal:

Expand Down
24 changes: 21 additions & 3 deletions rayflare/ray_tracing/rt_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ def calculate(self, options):
profile_interfaces = [item[8] for item in allres]
n_rem = np.stack([item[9] for item in allres])

final_pol = np.stack([item[10] for item in allres])
final_pol_vectors = np.stack([item[11] for item in allres])
final_intersection = np.stack([item[12] for item in allres])



if sum(self.tmm_or_fresnel) > 0:

A_per_interface = [
Expand Down Expand Up @@ -410,7 +416,7 @@ def calculate(self, options):
R0 = np.real(Is * refl_0).T / (n_reps * nx * ny)
R0 = np.sum(R0, 0)

return {
return State({
"R": R,
"T": T,
"A_per_layer": A_layer[:, 1:-1],
Expand All @@ -424,7 +430,7 @@ def calculate(self, options):
"interface_profiles": interface_profiles,
"Is": Is,
"xy": [xs, ys],
}
})

def calculate_profile(self, options):
prof_results = self.calculate(options)
Expand Down Expand Up @@ -659,6 +665,11 @@ def parallel_inner(
A_layer = np.zeros(len(widths))
Is = np.zeros(n_reps * nx * ny)

# ray attributes: I, d, r_a, pol, s_vector, p_vector
final_intersection = np.empty((n_reps * nx * ny, 3))*np.nan
final_pol = np.empty((n_reps * nx * ny, 2))*np.nan
final_pol_vectors = np.empty((n_reps * nx * ny, 2, 3))*np.nan

A_interfaces = [[] for _ in range(len(surfaces) + 1)]
local_thetas = [[] for _ in range(len(surfaces) + 1)]
local_pols = [[] for _ in range(len(surfaces) + 1)]
Expand Down Expand Up @@ -769,7 +780,7 @@ def parallel_inner(
# And polarization directions
ds, pols, pol_vectors, i_mats, i_dirs, surf_inds, n_remaining, I_in, n_inter_in, n_passes_in = (
make_rt_args(existing_rays, xs, ys, n_reps, phong_params, phong_options))
stop_before = int(np.ceil(n_remaining/(nx*ny)))
# stop_before = int(np.ceil(n_remaining/(nx*ny)))
# r_as need to be set so that z is somewhere within the current surface:
# z_offs = -cum_width[i_mats - 1] - 1e-8
z_min = np.array([surf.z_min for surf in surfaces])
Expand Down Expand Up @@ -845,6 +856,10 @@ def parallel_inner(
local_pols[A_interface_index].append(ray.pol)
directions[A_interface_index].append(direction)

final_pol[j1] = ray.pol
final_pol_vectors[j1] = [ray.s_vector, ray.p_vector]
final_intersection[j1] = ray.r_a

A_interfaces = A_interfaces[1:]
# index 0 are all entries for non-interface-absorption events.
local_thetas = local_thetas[1:]
Expand Down Expand Up @@ -906,6 +921,9 @@ def parallel_inner(
A_in_interfaces,
profile_arrays,
n_remaining,
final_pol,
final_pol_vectors,
final_intersection,
)

def calculate_interface_profiles(
Expand Down
1 change: 1 addition & 0 deletions rayflare/rigorous_coupled_wave_analysis/rcwa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,7 @@ def RCWA_structure_wl(
detailed_rcwa,
S4_options,
):
print("wl")
def vs_pol(s, p):
S.SetExcitationPlanewave((theta, phi), s, p, 0)
S.SetFrequency(1 / wl)
Expand Down
8 changes: 0 additions & 8 deletions tests/test_analytical_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,6 @@ def test_compare_TMM():

assert full_profile == approx(anlt_profile, rel=0.15, abs=1e-5)

def test_lambertian_scattering():
pass

def test_lambertian_scattering_integrated():
pass

# should have a test to check is Is, thetas calculate to correct R and T

def test_phong_scattering():
# phong scattering should give same result whether used with analytical or old ray-tracing.
# NOTE: currently, phong scattering is only applied when transferring to next surface! So need
Expand Down

0 comments on commit 6f0c955

Please sign in to comment.