Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for intermediate results to be stored during integration #17

Closed
8 tasks done
jrenaud90 opened this issue Jan 5, 2023 · 1 comment
Closed
8 tasks done
Labels
cython Issue related to cython-based code enhancement New feature or request good first issue Good for newcomers nbrk_ode An issue with the Numba solver
Milestone

Comments

@jrenaud90
Copy link
Owner

jrenaud90 commented Jan 5, 2023

In the current implementation of CyRK the only variables that are stored during integration are the dependent-y variables. For example,

# y = dy(t, y0)
t, y, success, message = nbrk_ode(dy, time_span, y0)

However, it is often useful to a user for additional parameters to be stored. For instance, a and b below.

def dy(t, y):
    dy_ = np.empty(2, dtype=np.complex128)
    a = g(t, y)  # Some function of time and y
    b = h(t, y)  # Some function of time and y
    dy_[0] = a * y[0]
    dy_[1] = b * y[1]
    return dy_

The values of a and b are lost after the integration is completed. The user would then need to make separate calls to the g and h function to retrieve their values. This is duplicating calculations and forcing the user to write additional code.

Propose CyRK stores these intermediate results during integration and returns them to the user.

One way this could be done is by having the user define the differential equation like,

def dy(t, y):
    dy_ = np.empty(2, dtype=np.complex128)
    a = g(t, y)  # Some function of time and y
    b = h(t, y)  # Some function of time and y
    dy_[0] = a * y[0]
    dy_[1] = b * y[1]
    return dy_, (a, b)

Then both cyrk_ode and nbrk_ode would store the result (probably best as a np.array) and return the result to the user.

To-Do

  • Implement intermediate saving for cyrk_ode
    • Implement basic saving
    • Implement interpolation for t_eval
    • Create tests
  • Implement intermediate saving for nbrk_ode
    • Implement basic saving
    • Implement interpolation for t_eval
    • Create tests
@jrenaud90 jrenaud90 added enhancement New feature or request good first issue Good for newcomers nbrk_ode An issue with the Numba solver cython Issue related to cython-based code labels Jan 5, 2023
@jrenaud90 jrenaud90 added this to the 1.1.0 milestone Jan 5, 2023
@jrenaud90
Copy link
Owner Author

This feature has been added, along with tests, with PR #18 in CyRK v0.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cython Issue related to cython-based code enhancement New feature or request good first issue Good for newcomers nbrk_ode An issue with the Numba solver
Projects
None yet
Development

No branches or pull requests

1 participant