From 6f0c955cdd04f7c61564d9f884ea8d496a111b70 Mon Sep 17 00:00:00 2001 From: Phoebe Pearce Date: Fri, 20 Sep 2024 09:10:42 +0200 Subject: [PATCH] more detailed outputs from rt_structure, doc updates --- docs/Examples/examples.rst | 5 ++++ docs/README.rst | 3 ++- docs/news.rst | 3 ++- rayflare/ray_tracing/rt_structure.py | 24 ++++++++++++++++--- .../rigorous_coupled_wave_analysis/rcwa.py | 1 + tests/test_analytical_rt.py | 8 ------- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/docs/Examples/examples.rst b/docs/Examples/examples.rst index 0aad892..7b7299c 100644 --- a/docs/Examples/examples.rst +++ b/docs/Examples/examples.rst @@ -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 ---------------------------------------------------------- diff --git a/docs/README.rst b/docs/README.rst index 1a3cb87..eec181d 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -9,7 +9,8 @@ optical models behind RayFlare, you can do that :ref:`here ` or get st Check the :ref:`news & updates page ` 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`_: diff --git a/docs/news.rst b/docs/news.rst index 60fdfc0..4b250bd 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -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: diff --git a/rayflare/ray_tracing/rt_structure.py b/rayflare/ray_tracing/rt_structure.py index 1159506..81fe2e9 100644 --- a/rayflare/ray_tracing/rt_structure.py +++ b/rayflare/ray_tracing/rt_structure.py @@ -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 = [ @@ -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], @@ -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) @@ -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)] @@ -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]) @@ -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:] @@ -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( diff --git a/rayflare/rigorous_coupled_wave_analysis/rcwa.py b/rayflare/rigorous_coupled_wave_analysis/rcwa.py index fefe29f..97bb70e 100644 --- a/rayflare/rigorous_coupled_wave_analysis/rcwa.py +++ b/rayflare/rigorous_coupled_wave_analysis/rcwa.py @@ -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) diff --git a/tests/test_analytical_rt.py b/tests/test_analytical_rt.py index 63cbfc4..878d04d 100644 --- a/tests/test_analytical_rt.py +++ b/tests/test_analytical_rt.py @@ -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