Skip to content

Examples for CVodeResizeHistory when y changes size #715

@martinwang2002

Description

@martinwang2002

CVodeResizeHistory is a very nice function and I am glad it was released in v7.3.0. I'm working on a project that requires dynamically resizing the ODE system during integration using CVodeResizeHistory(). While the documentation explains the API, I’m unclear on how to handle some scenarios.

1. Resizing when the solution vector y changes size

  • When the ODE system increases or decreases in size, how should y_hist and f_hist be constructed to accommodate the new variables?

  • For example, consider this case:

    Time t_n t_{n-1} t_{n-2} t_{n-3}
    Number of equations 6 5 4 5
    Notes y6 added shrinks below original intermediate (y1) or last (y5) removed back to original size
  • What should the sizes of y_hist and f_hist be in this case?
    At t_n, should the sizes of the vectors in history remain as [6, 5, 4, 5], or should all history vectors be resized to [6, 6, 6, 6] to match the new system size?

  • If resizing history vectors, how should the new components be filled? Is zero-initialization acceptable, or should they be extrapolated or estimated in a specific way?


2. Clarification on test behavior

In this test case, I noticed two different behaviors:

// resize = 0 -- do not resize
// resize = 1 -- call resize but with the same problem size
// resize = 2 -- grow the problem by one element each time step

  • Resizing while keeping the same problem size
  • Growing the problem by one element each time step

Could you clarify the purpose of each approach? How do they differ in terms of results, stability, or accuracy?


3. Request for a complete working example

It would be incredibly helpful to see a full example that demonstrates a dynamic resize where the number of unknowns (NEQ) both expands and shrinks


Thank you for your work on this excellent integration library!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions