Skip to content

Commit

Permalink
add refract_shell and refract_core
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed Oct 10, 2023
1 parent 85aa967 commit ad7989b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/aero_particle.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions src/aero_particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "aero_data.hpp"
#include "env_state.hpp"
#include "pybind11/stl.h"
#include <complex>

extern "C" void f_aero_particle_ctor(void *ptr) noexcept;
extern "C" void f_aero_particle_dtor(void *ptr) noexcept;
Expand Down Expand Up @@ -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<double> *val) noexcept;
extern "C" void f_aero_particle_refract_core(const void *aero_particle_ptr, std::complex<double> *val) noexcept;

namespace py = pybind11;
struct AeroParticle {
Expand Down Expand Up @@ -345,4 +348,21 @@ struct AeroParticle {
return val;
}

static auto refract_shell(const AeroParticle &self) {
std::complex<double> 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<double> refract_core;
f_aero_particle_refract_core(
self.ptr.f_arg(),
&refract_core
);
return refract_core;
}
};
5 changes: 5 additions & 0 deletions src/pypartmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ad7989b

Please sign in to comment.