-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,365 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
cimport numpy as np | ||
from libcpp cimport bool as bool_cpp_t | ||
cdef class CySolver: | ||
|
||
# Class attributes | ||
# -- Live variables | ||
cdef double t_new, t_old | ||
cdef unsigned int len_t | ||
cdef double[:] y_new_view, y_old_view, dy_new_view, dy_old_view | ||
cdef double[:] extra_output_view, extra_output_init_view | ||
|
||
# -- Dependent (y0) variable information | ||
cdef unsigned short y_size | ||
cdef double y_size_dbl, y_size_sqrt | ||
cdef const double[:] y0_view | ||
|
||
# -- RK method information | ||
cdef unsigned char rk_method | ||
cdef unsigned char rk_order, error_order, rk_n_stages, rk_n_stages_plus1, rk_n_stages_extended | ||
cdef double error_expo | ||
cdef unsigned char len_C | ||
cdef double[:] B_view, E_view, E3_view, E5_view, E_tmp_view, E3_tmp_view, E5_tmp_view, C_view | ||
cdef double[:, :] A_view, K_view | ||
|
||
# -- Integration information | ||
cdef public char status | ||
cdef public str message | ||
cdef public bool_cpp_t success | ||
cdef double t_start, t_end, t_delta, t_delta_abs, direction, direction_inf | ||
cdef double rtol, atol | ||
cdef double step_size, max_step | ||
cdef unsigned int expected_size | ||
cdef unsigned int num_concats | ||
|
||
# -- Optional args info | ||
cdef unsigned short num_args | ||
cdef double[:] arg_array_view | ||
|
||
# -- Extra output info | ||
cdef bool_cpp_t capture_extra | ||
cdef unsigned short num_extra | ||
|
||
# -- Interpolation info | ||
cdef bool_cpp_t run_interpolation | ||
cdef bool_cpp_t interpolate_extra | ||
cdef unsigned int len_t_eval | ||
cdef double[:] t_eval_view | ||
|
||
# -- Solution variables | ||
cdef double[:, :] solution_y_view, solution_extra_view | ||
cdef double[:] solution_t_view | ||
|
||
# Class functions | ||
cdef double calc_first_step(self) | ||
cpdef void solve(self) | ||
cdef void _solve(self) | ||
cdef void interpolate(self) | ||
cdef void diffeq(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# distutils: language = c++ | ||
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False | ||
|
||
import cython | ||
import numpy as np | ||
cimport numpy as np | ||
np.import_array() | ||
from libc.math cimport sin, cos | ||
|
||
from CyRK.cy.cysolver cimport CySolver | ||
|
||
|
||
cdef class CySolverTester(CySolver): | ||
|
||
@cython.exceptval(check=False) | ||
cdef void diffeq(self): | ||
|
||
# Unpack y | ||
cdef double y0, y1 | ||
y0 = self.y_new_view[0] | ||
y1 = self.y_new_view[1] | ||
|
||
self.dy_new_view[0] = (1. - 0.01 * y1) * y0 | ||
self.dy_new_view[1] = (0.02 * y0 - 1.) * y1 | ||
|
||
|
||
cdef class CySolverAccuracyTest(CySolver): | ||
|
||
@cython.exceptval(check=False) | ||
cdef void diffeq(self): | ||
|
||
# Unpack y | ||
cdef double y0, y1 | ||
y0 = self.y_new_view[0] | ||
y1 = self.y_new_view[1] | ||
|
||
self.dy_new_view[0] = sin(self.t_new) - y1 | ||
self.dy_new_view[1] = cos(self.t_new) + y0 | ||
|
||
|
||
cdef class CySolverExtraTest(CySolver): | ||
|
||
@cython.exceptval(check=False) | ||
cdef void diffeq(self): | ||
|
||
# Unpack y | ||
cdef double y0, y1, extra_0, extra_1 | ||
y0 = self.y_new_view[0] | ||
y1 = self.y_new_view[1] | ||
|
||
extra_0 = (1. - 0.01 * y1) | ||
extra_1 = (0.02 * y0 - 1.) | ||
|
||
self.dy_new_view[0] = extra_0 * y0 | ||
self.dy_new_view[1] = extra_1 * y1 | ||
|
||
self.extra_output_view[0] = extra_0 | ||
self.extra_output_view[1] = extra_1 |
Oops, something went wrong.