Skip to content

Commit 6b412ca

Browse files
authored
bump PartMC submodule and expose additive kernel coefficient property (#385)
1 parent 2e48fc6 commit 6b412ca

File tree

5 files changed

+56
-1
lines changed

5 files changed

+56
-1
lines changed

src/env_state.F90

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ subroutine f_env_state_get_height(ptr_c, height) bind(C)
9494

9595
end subroutine
9696

97+
subroutine f_env_state_set_additive_kernel_coefficient(ptr_c, value) bind(C)
98+
type(env_state_t), pointer :: ptr_f => null()
99+
type(c_ptr), intent(in) :: ptr_c
100+
real(c_double), intent(in) :: value
101+
102+
call c_f_pointer(ptr_c, ptr_f)
103+
104+
ptr_f%additive_kernel_coefficient = value
105+
106+
end subroutine
107+
108+
subroutine f_env_state_get_additive_kernel_coefficient(ptr_c, target) bind(C)
109+
type(env_state_t), pointer :: ptr_f => null()
110+
type(c_ptr), intent(in) :: ptr_c
111+
real(c_double), intent(out) :: target
112+
113+
call c_f_pointer(ptr_c, ptr_f)
114+
115+
target = ptr_f%additive_kernel_coefficient
116+
117+
end subroutine
118+
97119
subroutine f_env_state_set_pressure(ptr_c, pressure) bind(C)
98120
type(env_state_t), pointer :: ptr_f => null()
99121
type(c_ptr), intent(in) :: ptr_c

src/env_state.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ extern "C" void f_env_state_dtor(void *ptr) noexcept;
1414
extern "C" void f_env_state_from_json(const void *ptr) noexcept;
1515
extern "C" void f_env_state_set_temperature(const void *ptr, const double *temperature) noexcept;
1616
extern "C" void f_env_state_get_temperature(const void *ptr, double *temperature) noexcept;
17+
extern "C" void f_env_state_set_additive_kernel_coefficient(const void *ptr, const double *additive_kernel_coefficient) noexcept;
18+
extern "C" void f_env_state_get_additive_kernel_coefficient(const void *ptr, double *additive_kernel_coefficient) noexcept;
1719
extern "C" void f_env_state_get_rel_humid(const void *ptr, double *rel_humid) noexcept;
1820
extern "C" void f_env_state_set_height(const void *ptr, const double *height) noexcept;
1921
extern "C" void f_env_state_get_height(const void *ptr, double *height) noexcept;
@@ -82,6 +84,23 @@ struct EnvState {
8284
return height;
8385
}
8486

87+
static void set_additive_kernel_coefficient(const EnvState &self, const double additive_kernel_coefficient) {
88+
f_env_state_set_additive_kernel_coefficient(
89+
self.ptr.f_arg(),
90+
&additive_kernel_coefficient
91+
);
92+
}
93+
94+
static auto get_additive_kernel_coefficient(const EnvState &self) {
95+
double additive_kernel_coefficient;
96+
97+
f_env_state_get_additive_kernel_coefficient(
98+
self.ptr.f_arg(),
99+
&additive_kernel_coefficient
100+
);
101+
return additive_kernel_coefficient;
102+
}
103+
85104
static void set_pressure(const EnvState &self, const double pressure) {
86105
f_env_state_set_pressure(
87106
self.ptr.f_arg(),

src/pypartmc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ PYBIND11_MODULE(_PyPartMC, m) {
324324
"Ambient pressure (Pa)")
325325
.def_property_readonly("air_density", &EnvState::air_density,
326326
"Air density (kg m^{-3})")
327+
.def_property("additive_kernel_coefficient", &EnvState::get_additive_kernel_coefficient, &EnvState::set_additive_kernel_coefficient,
328+
"Scaling coefficient for additive coagulation kernel.")
327329
;
328330

329331
py::class_<Photolysis>(m,

tests/test_env_state.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ def test_pressure():
7272
# assert
7373
assert value == sut.pressure
7474

75+
@staticmethod
76+
def test_additive_kernel_coefficient():
77+
# arrange
78+
sut = ppmc.EnvState(ENV_STATE_CTOR_ARG_MINIMAL)
79+
value = 1500.0
80+
81+
# act
82+
sut.additive_kernel_coefficient = value
83+
84+
# assert
85+
assert value == sut.additive_kernel_coefficient
86+
7587
@staticmethod
7688
def test_humidity_ctor():
7789
# arrange and act

0 commit comments

Comments
 (0)