Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrenaud90 committed Nov 28, 2024
1 parent 8d28572 commit 66246c5
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 54 deletions.
3 changes: 1 addition & 2 deletions CyRK/cy/cysolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ void CySolverResult::build_solver(
DiffeqFuncType diffeq_ptr,
const double t_start,
const double t_end,
const double* y0_ptr,
const double* const y0_ptr,
const int method,
// General optional arguments
const size_t expected_size,
const void* args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const bool dense_output,
const double* t_eval,
const size_t len_t_eval,
PreEvalFunc pre_eval_func,
Expand Down
3 changes: 1 addition & 2 deletions CyRK/cy/cysolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,13 @@ class CySolverResult : public std::enable_shared_from_this<CySolverResult>{
DiffeqFuncType diffeq_ptr,
const double t_start,
const double t_end,
const double* y0_ptr,
const double* const y0_ptr,
const int method,
// General optional arguments
const size_t expected_size,
const void* args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const bool dense_output,
const double* t_eval,
const size_t len_t_eval,
PreEvalFunc pre_eval_func,
Expand Down
6 changes: 2 additions & 4 deletions CyRK/cy/cysolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ void baseline_cysolve_ivp_noreturn(
args_ptr,
max_num_steps,
max_ram_MB,
dense_output,
t_eval,
len_t_eval,
pre_eval_func,
Expand Down Expand Up @@ -222,7 +221,7 @@ PySolver::PySolver(
if (this->solution_sptr) [[likely]]
{
this->solution_sptr->build_solver(
diffeq_ptr,
diffeq_ptr, // not used when using pysolver
t_start,
t_end,
y0_ptr,
Expand All @@ -232,10 +231,9 @@ PySolver::PySolver(
args_ptr,
max_num_steps,
max_ram_MB,
dense_output,
t_eval,
len_t_eval,
pre_eval_func,
pre_eval_func, // not used when using pysolver
// rk optional arguments
rtol,
atol,
Expand Down
30 changes: 15 additions & 15 deletions CyRK/cy/cysolve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ std::shared_ptr<CySolverResult> baseline_cysolve_ivp(
const size_t num_y,
const int method,
// General optional arguments
const size_t expected_size = 0,
const size_t num_extra = 0,
const void* args_ptr = nullptr,
const size_t max_num_steps = 0,
const size_t max_ram_MB = 2000,
const bool dense_output = false,
const double* t_eval = nullptr,
const size_t len_t_eval = 0,
PreEvalFunc pre_eval_func = nullptr,
const size_t expected_size,
const size_t num_extra,
void* args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const bool dense_output,
const double* t_eval,
const size_t len_t_eval,
PreEvalFunc pre_eval_func,
// rk optional arguments
const double rtol = 1.0e-3,
const double atol = 1.0e-6,
const double* rtols_ptr = nullptr,
const double* atols_ptr = nullptr,
const double max_step_size = MAX_STEP,
const double first_step_size = 0.0
const double rtol,
const double atol,
const double* rtols_ptr,
const double* atols_ptr,
const double max_step_size,
const double first_step_size
);


Expand Down
6 changes: 6 additions & 0 deletions CyRK/cy/cysolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ CySolverBase::~CySolverBase()
// Decrease reference count on the cython extension class instance
Py_XDECREF(this->cython_extension_class_instance);
}

// Reset shared pointers
if (this->storage_sptr)
{
this->storage_sptr.reset();
}
}

// Protected methods
Expand Down
18 changes: 9 additions & 9 deletions CyRK/cy/cysolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ class CySolverBase {
const double t_end,
const double* const y0_ptr,
const size_t num_y,
const size_t num_extra = 0,
const void* const args_ptr = nullptr,
const size_t max_num_steps = 0,
const size_t max_ram_MB = 2000,
const bool use_dense_output = false,
const double* t_eval = nullptr,
const size_t len_t_eval = 0,
PreEvalFunc pre_eval_func = nullptr
const size_t num_extra,
void args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const bool use_dense_output,
const double* t_eval,
const size_t len_t_eval,
PreEvalFunc pre_eval_func
);

bool check_status() const;
Expand Down Expand Up @@ -104,7 +104,7 @@ class CySolverBase {
// Integration step information
size_t max_num_steps = 0;

// Differential equation information
// Differential equation information
const void* args_ptr = nullptr;
DiffeqFuncType diffeq_ptr = nullptr;

Expand Down
1 change: 0 additions & 1 deletion CyRK/cy/cysolver_api.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ cdef extern from "cysolution.cpp" nogil:
const void* args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const cpp_bool dense_output,
const double* t_eval,
const size_t len_t_eval,
PreEvalFunc pre_eval_func,
Expand Down
1 change: 0 additions & 1 deletion CyRK/cy/cysolver_api.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# distutils: language = c++
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False

import numpy as np
cimport numpy as cnp
cnp.import_array()
Expand Down
6 changes: 1 addition & 5 deletions CyRK/cy/cysolver_test.pxd
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
from libcpp cimport bool as cpp_bool

from libc.math cimport sin, cos, fabs, fmin, fmax

from CyRK.cy.cysolver_api cimport cysolve_ivp, WrapCySolverResult, DiffeqFuncType,MAX_STEP, CySolveOutput, PreEvalFunc
from CyRK.cy.cysolver_api cimport PreEvalFunc

cdef void baseline_diffeq(double* dy_ptr, double t, double* y_ptr, const void* args_ptr, PreEvalFunc pre_eval_func) noexcept nogil
cdef void accuracy_test_diffeq(double* dy_ptr, double t, double* y_ptr, const void* args_ptr, PreEvalFunc pre_eval_func) noexcept nogil
Expand Down
13 changes: 13 additions & 0 deletions CyRK/cy/cysolver_test.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# distutils: language = c++
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False

from libcpp cimport bool as cpp_bool
from libcpp.memory cimport make_shared, shared_ptr
from libcpp.vector cimport vector
from libcpp.limits cimport numeric_limits
from libc.math cimport sin, cos, fabs, fmin, fmax

cdef double d_NAN = numeric_limits[double].quiet_NaN()

from CyRK.cy.cysolver_api cimport cysolve_ivp, WrapCySolverResult, DiffeqFuncType,MAX_STEP, CySolveOutput, null_void_sptr

import numpy as np
cimport numpy as np
np.import_array()


cdef void baseline_diffeq(double* dy_ptr, double t, double* y_ptr, const void* args_ptr, PreEvalFunc pre_eval_func) noexcept nogil:
# Unpack y
Expand Down
2 changes: 1 addition & 1 deletion CyRK/cy/pysolver.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def pysolve_ivp(
# Finally we can actually run the integrator!
# The following effectively copies the functionality of cysolve_ivp. We can not directly use that function
# because we need to tie in the python-based diffeq function (via its wrapper)

# Build null pointers to unused arguments
cdef void* args_ptr = NULL

Expand Down
6 changes: 3 additions & 3 deletions CyRK/cy/rk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ RKSolver::RKSolver() {}
RKSolver::RKSolver(
// Base Class input arguments
DiffeqFuncType diffeq_ptr,
std::shared_ptr<CySolverResult> const storage_sptr,
std::shared_ptr<CySolverResult> storage_sptr,
const double t_start,
const double t_end,
const double* y0_ptr,
const double* const y0_ptr,
const size_t num_y,
const size_t num_extra,
const void* args_ptr,
void* args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const bool use_dense_output,
Expand Down
20 changes: 10 additions & 10 deletions CyRK/cy/rk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,19 +711,19 @@ class RKSolver : public CySolverBase {
RKSolver(
// Base Class input arguments
DiffeqFuncType diffeq_ptr,
std::shared_ptr<CySolverResult> const storage_sptr,
std::shared_ptr<CySolverResult> storage_sptr,
const double t_start,
const double t_end,
const double* y0_ptr,
const double* const y0_ptr,
const size_t num_y,
const size_t num_extra = 0,
const void* args_ptr = nullptr,
const size_t max_num_steps = 0,
const size_t max_ram_MB = 2000,
const bool use_dense_output = false,
const double* t_eval = nullptr,
const size_t len_t_eval = 0,
PreEvalFunc pre_eval_func = nullptr,
const size_t num_extra,
void* args_ptr,
const size_t max_num_steps,
const size_t max_ram_MB,
const bool use_dense_output,
const double* t_eval,
const size_t len_t_eval,
PreEvalFunc pre_eval_func,
// RKSolver input arguments
const double rtol = 1.0e-3,
const double atol = 1.0e-6,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name='CyRK'
version = '0.11.6a0.dev0'
version = '0.11.6a0.dev1'
description='Runge-Kutta ODE Integrator Implemented in Cython and Numba.'
authors= [
{name = 'Joe P. Renaud', email = 'joe.p.renaud@gmail.com'}
Expand Down

0 comments on commit 66246c5

Please sign in to comment.