From ad7989bbeb14198d382815182d0621ca04c5e83c Mon Sep 17 00:00:00 2001 From: Jeff Curtis Date: Tue, 10 Oct 2023 13:21:56 -0500 Subject: [PATCH] add refract_shell and refract_core --- src/aero_particle.F90 | 30 ++++++++++++++++++++++++++++++ src/aero_particle.hpp | 20 ++++++++++++++++++++ src/pypartmc.cpp | 5 +++++ 3 files changed, 55 insertions(+) diff --git a/src/aero_particle.F90 b/src/aero_particle.F90 index 050aa858..31ed8e9d 100644 --- a/src/aero_particle.F90 +++ b/src/aero_particle.F90 @@ -494,4 +494,34 @@ subroutine f_aero_particle_id( & end subroutine + subroutine f_aero_particle_refract_shell( & + aero_particle_ptr_c, & + refract_shell & + ) bind(C) + + type(aero_particle_t), pointer :: aero_particle_ptr_f => null() + type(c_ptr), intent(in) :: aero_particle_ptr_c + complex(c_double_complex), intent(out) :: refract_shell + + call c_f_pointer(aero_particle_ptr_c, aero_particle_ptr_f) + + refract_shell = aero_particle_ptr_f%refract_shell + + end subroutine + + subroutine f_aero_particle_refract_core( & + aero_particle_ptr_c, & + refract_core & + ) bind(C) + + type(aero_particle_t), pointer :: aero_particle_ptr_f => null() + type(c_ptr), intent(in) :: aero_particle_ptr_c + complex(c_double_complex), intent(out) :: refract_core + + call c_f_pointer(aero_particle_ptr_c, aero_particle_ptr_f) + + refract_core = aero_particle_ptr_f%refract_core + + end subroutine + end module diff --git a/src/aero_particle.hpp b/src/aero_particle.hpp index e2be6c2a..b67c7f4c 100644 --- a/src/aero_particle.hpp +++ b/src/aero_particle.hpp @@ -10,6 +10,7 @@ #include "aero_data.hpp" #include "env_state.hpp" #include "pybind11/stl.h" +#include extern "C" void f_aero_particle_ctor(void *ptr) noexcept; extern "C" void f_aero_particle_dtor(void *ptr) noexcept; @@ -42,6 +43,8 @@ extern "C" void f_aero_particle_greatest_create_time(const void *aero_particle_p extern "C" void f_aero_particle_least_create_time(const void *aero_particle_ptr, double *val) noexcept; extern "C" void f_aero_particle_n_orig_part(const void *aero_particle_ptr, void *arr_data, const int *arr_size) noexcept; extern "C" void f_aero_particle_id(const void *aero_particle_ptr, int *val) noexcept; +extern "C" void f_aero_particle_refract_shell(const void *aero_particle_ptr, std::complex *val) noexcept; +extern "C" void f_aero_particle_refract_core(const void *aero_particle_ptr, std::complex *val) noexcept; namespace py = pybind11; struct AeroParticle { @@ -345,4 +348,21 @@ struct AeroParticle { return val; } + static auto refract_shell(const AeroParticle &self) { + std::complex refract_shell; + f_aero_particle_refract_shell( + self.ptr.f_arg(), + &refract_shell + ); + return refract_shell; + } + + static auto refract_core(const AeroParticle &self) { + std::complex refract_core; + f_aero_particle_refract_core( + self.ptr.f_arg(), + &refract_core + ); + return refract_core; + } }; diff --git a/src/pypartmc.cpp b/src/pypartmc.cpp index 76e921c1..b98249d6 100644 --- a/src/pypartmc.cpp +++ b/src/pypartmc.cpp @@ -7,6 +7,7 @@ #include "pybind11/pybind11.h" #include "nlohmann/json.hpp" #include "pybind11_json/pybind11_json.hpp" +#include "pybind11/complex.h" #include "util.hpp" #include "rand.hpp" @@ -135,6 +136,10 @@ PYBIND11_MODULE(_PyPartMC, m) { "Scattering cross-section (m^-2).") .def_property_readonly("asymmetry", AeroParticle::asymmetry, "Asymmetry parameter (1).") + .def_property_readonly("refract_shell", AeroParticle::refract_shell, + "Refractive index of the shell (1).") + .def_property_readonly("refract_core", AeroParticle::refract_core, + "Refractive index of the core (1).") .def_property_readonly("n_orig_part", AeroParticle::n_orig_part, "Number of original particles from each source that coagulated to form particle.") .def_property_readonly("least_create_time", AeroParticle::least_create_time,