CyRK.cy

Submodules

CyRK.cy.common module

class CyRK.cy.common.CyrkErrorCodes(*values)

Bases: IntEnum

ARGUMENT_ERROR = -10
ARGUMENT_NOT_SET = -9
ATTRIBUTE_ERROR = -7
BAD_CONFIG_DATA = -22
BAD_INITIAL_STEP_SIZE = -80
BOUNDS_ERROR = -8
CONVERGED = 20
CYSOLVER_INITIALIZATION_ERROR = -5
DENSE_BUILD_FAILED = -56
DENSE_OUTPUT_NOT_SAVED = -21
ERROR_IMPORTING_PYTHON_MODULE = -70
EVENT_SETUP_FAILED = -60
EVENT_TERMINATED = 2
GENERAL_ERROR = -1
INCOMPATIBLE_INPUT = -6
INITIALIZING = 10
INTEGRATION_NOT_SUCCESSFUL = -57
JACOBIAN_IS_SINGULAR = -90
LSODA_INTERNAL_ERROR = -92
MAX_ITERATIONS_HIT = -51
MAX_STEPS_SYSARCH_EXCEEDED = -53
MAX_STEPS_USER_EXCEEDED = -52
MEMORY_ALLOCATION_ERROR = -40
NEWTON_CONVERGENCE_ERROR = -91
NO_ERROR = 0
NUMBER_OF_EQUATIONS_IS_ZERO = -50
OPTIMIZE_CONVERGENCE_ERROR = -31
OPTIMIZE_SIGN_ERROR = -30
OTHER_ERROR = -99
PROPERTY_NOT_SET = -2
PYTHON_FUNCTION_ERROR = -71
SETUP_NOT_CALLED = -20
STEP_SIZE_ERROR_ACCEPTANCE = -55
STEP_SIZE_ERROR_SPACING = -54
SUCCESSFUL_INTEGRATION = 1
UNINITIALIZED_CLASS = -4
UNSET_ERROR_CODE = -100
UNSUPPORTED_UNKNOWN_MODEL = -3
VECTOR_SIZE_EXCEEDS_LIMITS = -41
CyRK.cy.common.get_error_message(error_code)

Return the message for a CyRK status or error code.

Parameters:

error_code (int) – A CyrkErrorCodes member or its integer value.

Returns:

The code’s message, or a generic “unknown error code” message if CyRK defines none for it.

Return type:

str

CyRK.cy.cysolver_api module

class CyRK.cy.cysolver_api.ODEMethod(*values)

Bases: IntEnum

BASE_METHOD = 1
BDF = 6
DOP853 = 5
LSODA = 7
NO_METHOD_SET = 0
RADAU = 8
RK23 = 3
RK45 = 4
RK_BASE_METHOD = 2
TSIT5 = 9
VERN7 = 10
VERN8 = 11
class CyRK.cy.cysolver_api.WrapCySolverResult

Bases: object

Wrapper for the C++ class CySolverResult defined in “cysolution.cpp”

call(t)

Call the dense output interpolater and return y

call_vectorize(t_view)

Call the dense output interpolater and return y

error_code
event_terminate_index
event_terminated
finalize()
integration_method

Returns a string stating what integration method was used for this solution.

message
method

Alias for self.integration_method.

num_dy
num_events
num_y
print_diagnostics()
size
solve()
status
status_message
steps_taken
success
t
t_events
y
y_events

CyRK.cy.cysolver_test module

CyRK.cy.cysolver_test.cy_extra_output_tester()
CyRK.cy.cysolver_test.cytester(diffeq_number, t_span=None, y0=None, args=None, method='rk45', expected_size=0, max_num_steps=0, max_ram_MB=2000, dense_output=False, use_events=False, t_eval=None, rtol=0.001, atol=1e-06, rtol_array=None, atol_array=None, max_step=inf, first_step=0.0, solution_reuse=None, force_retain_solver=False, repeats=1, use_jacobian=False)

CyRK.cy.events module

CyRK.cy.events_test module

CyRK.cy.events_test.build_event_wrapper_test()
CyRK.cy.events_test.run_cysolver_with_events(use_dense, t_eval, use_termination, capture_extra)

CyRK.cy.helpers module

CyRK.cy.parallel_test module

Checks that CySolver can be driven from several C++ threads at once.

Every job solves the same Lotka-Volterra problem through c_cysolve_batch, and the results are compared with the first job’s, so any interference between threads shows up as a mismatch. Each runner returns its wall-clock time so the tests can compare thread counts. This module is also the worked example for CyRK.cy.parallel.

CyRK.cy.parallel_test.run_dense_output_threads_test(num_threads=4, num_repeats=100)

Solve a Lorenz problem with extra outputs once, then read its dense output from num_threads C++ threads.

Every thread compares each read, extra outputs included, with a serial read at the same time. A dense read only reads the shared solution, so no read may differ. Returns the number of reads that did.

CyRK.cy.parallel_test.run_parallel_benchmark(num_threads, num_runs, t_end)

Time num_runs identical Lotka-Volterra solves to t_end on num_threads threads; returns the ms taken.

Use it to find where threading starts to pay off on your machine. The per-job time grows with t_end (the solution is periodic, so the step count is proportional to it) on top of the solver’s fixed setup cost.

CyRK.cy.parallel_test.run_parallel_common_args_test(num_threads=2)

Solve a batch where every job reads the same argument vector, spread over num_threads C++ threads.

CyRK.cy.parallel_test.run_parallel_test(num_threads=2)

Solve a batch where each job has its own argument vector, spread over num_threads C++ threads.

CyRK.cy.pyhelpers module

CyRK.cy.pyhelpers.find_ode_method_int(ode_method_name: str)[source]

CyRK.cy.pysolver module

class CyRK.cy.pysolver.PySolver

Bases: WrapCySolverResult

call(t)

Call the dense output interpolater and return y

call_vectorize(t_view)

Call the dense output interpolater and return y

set_problem_parameters(py_diffeq, time_span, y0, method='RK45', t_eval=None, dense_output=False, events=None, args=None, expected_size=0, num_extra=0, first_step=0.0, max_step=inf, rtol=0.001, atol=1e-06, max_num_steps=0, max_ram_MB=2000, pass_dy_as_arg=False, force_retain_solver=True, min_step=0.0, lband=None, uband=None)
set_pydiffeq(diffeq_func, args, num_y, num_dy, pass_dy_as_arg=False)
solve()
CyRK.cy.pysolver.pysolve_ivp(py_diffeq, time_span, y0, method='RK45', t_eval=None, dense_output=False, events=None, args=None, expected_size=0, num_extra=0, first_step=0.0, max_step=inf, rtol=0.001, atol=1e-06, max_num_steps=0, max_ram_MB=2000, pass_dy_as_arg=False, solution_reuse=None, force_retain_solver=True, min_step=0.0, lband=None, uband=None)

CyRK.cy.pysolver_cyhook module