Skip to content

Commit

Permalink
bump PartMC submodule and expose additive kernel coefficient property (
Browse files Browse the repository at this point in the history
  • Loading branch information
emmacware authored Dec 6, 2024
1 parent 2e48fc6 commit 6b412ca
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/env_state.F90
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ subroutine f_env_state_get_height(ptr_c, height) bind(C)

end subroutine

subroutine f_env_state_set_additive_kernel_coefficient(ptr_c, value) bind(C)
type(env_state_t), pointer :: ptr_f => null()
type(c_ptr), intent(in) :: ptr_c
real(c_double), intent(in) :: value

call c_f_pointer(ptr_c, ptr_f)

ptr_f%additive_kernel_coefficient = value

end subroutine

subroutine f_env_state_get_additive_kernel_coefficient(ptr_c, target) bind(C)
type(env_state_t), pointer :: ptr_f => null()
type(c_ptr), intent(in) :: ptr_c
real(c_double), intent(out) :: target

call c_f_pointer(ptr_c, ptr_f)

target = ptr_f%additive_kernel_coefficient

end subroutine

subroutine f_env_state_set_pressure(ptr_c, pressure) bind(C)
type(env_state_t), pointer :: ptr_f => null()
type(c_ptr), intent(in) :: ptr_c
Expand Down
19 changes: 19 additions & 0 deletions src/env_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extern "C" void f_env_state_dtor(void *ptr) noexcept;
extern "C" void f_env_state_from_json(const void *ptr) noexcept;
extern "C" void f_env_state_set_temperature(const void *ptr, const double *temperature) noexcept;
extern "C" void f_env_state_get_temperature(const void *ptr, double *temperature) noexcept;
extern "C" void f_env_state_set_additive_kernel_coefficient(const void *ptr, const double *additive_kernel_coefficient) noexcept;
extern "C" void f_env_state_get_additive_kernel_coefficient(const void *ptr, double *additive_kernel_coefficient) noexcept;
extern "C" void f_env_state_get_rel_humid(const void *ptr, double *rel_humid) noexcept;
extern "C" void f_env_state_set_height(const void *ptr, const double *height) noexcept;
extern "C" void f_env_state_get_height(const void *ptr, double *height) noexcept;
Expand Down Expand Up @@ -82,6 +84,23 @@ struct EnvState {
return height;
}

static void set_additive_kernel_coefficient(const EnvState &self, const double additive_kernel_coefficient) {
f_env_state_set_additive_kernel_coefficient(
self.ptr.f_arg(),
&additive_kernel_coefficient
);
}

static auto get_additive_kernel_coefficient(const EnvState &self) {
double additive_kernel_coefficient;

f_env_state_get_additive_kernel_coefficient(
self.ptr.f_arg(),
&additive_kernel_coefficient
);
return additive_kernel_coefficient;
}

static void set_pressure(const EnvState &self, const double pressure) {
f_env_state_set_pressure(
self.ptr.f_arg(),
Expand Down
2 changes: 2 additions & 0 deletions src/pypartmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ PYBIND11_MODULE(_PyPartMC, m) {
"Ambient pressure (Pa)")
.def_property_readonly("air_density", &EnvState::air_density,
"Air density (kg m^{-3})")
.def_property("additive_kernel_coefficient", &EnvState::get_additive_kernel_coefficient, &EnvState::set_additive_kernel_coefficient,
"Scaling coefficient for additive coagulation kernel.")
;

py::class_<Photolysis>(m,
Expand Down
12 changes: 12 additions & 0 deletions tests/test_env_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ def test_pressure():
# assert
assert value == sut.pressure

@staticmethod
def test_additive_kernel_coefficient():
# arrange
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
value = 1500.0

# act
sut.additive_kernel_coefficient = value

# assert
assert value == sut.additive_kernel_coefficient

@staticmethod
def test_humidity_ctor():
# arrange and act
Expand Down

0 comments on commit 6b412ca

Please sign in to comment.