Skip to content

Commit

Permalink
Added tracker for steps taken during integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jrenaud90 committed Nov 27, 2024
1 parent 69b67f7 commit ba9a21c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 2024

#### v0.11.4 (2024-11-27)

New:
* Added a `steps_taken` tracking variable to the C++ class `CySolverResult` and the Cython wrapped `WrapCySolverResult` so that users can see how many steps were taken during integration even when using `t_eval`.

#### v0.11.4 (2024-11-25)

C++ Changes
Expand Down
3 changes: 2 additions & 1 deletion CyRK/cy/cysolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ void CySolverResult::reset()
this->storage_capacity = this->original_expected_size;

// Reset trackers
this->size = 0;
this->size = 0;
this->num_interpolates = 0;
this->steps_taken = 0;

// Reserve the memory for the vectors
try
Expand Down
3 changes: 2 additions & 1 deletion CyRK/cy/cysolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ class CySolverResult : public std::enable_shared_from_this<CySolverResult>{

// More status information
char* message_ptr = &message[0];
size_t size = 0;
size_t size = 0;
size_t num_interpolates = 0;
size_t steps_taken = 0;

// Pointer to storage arrays
std::vector<double> time_domain_vec = std::vector<double>();
Expand Down
1 change: 1 addition & 0 deletions CyRK/cy/cysolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void CySolverBase::take_step()

this->p_step_implementation();
this->len_t++;
this->storage_sptr->steps_taken++;

// Take care of dense output and t_eval
int dense_built = 0;
Expand Down
1 change: 1 addition & 0 deletions CyRK/cy/cysolver_api.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ cdef extern from "cysolution.cpp" nogil:
char* message_ptr
size_t size
size_t num_interpolates
size_t steps_taken
vector[double] time_domain_vec
vector[double] time_domain_vec_sorted
vector[double] solution
Expand Down
4 changes: 4 additions & 0 deletions CyRK/cy/cysolver_api.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ cdef class WrapCySolverResult:
def size(self):
return self.cyresult_ptr.size

@property
def steps_taken(self):
return self.cyresult_ptr.steps_taken

@property
def num_y(self):
return self.cyresult_ptr.num_y
Expand Down
1 change: 1 addition & 0 deletions Tests/D_PySolver_Tests/test_a_pysolve_ivp.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def test_pysolve_ivp(use_scipy_style, use_args, use_njit_always,
assert result.success
assert result.error_code == 1
assert result.size > 1
assert result.steps_taken > 1
assert result.message == "Integration completed without issue."
# Check that the ndarrays make sense
assert type(result.t) == np.ndarray
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.4'
version = '0.11.5'
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 ba9a21c

Please sign in to comment.