|
| 1 | +# Sundials.jl NEWS |
| 2 | + |
| 3 | +## v5.0.0 |
| 4 | + |
| 5 | +### Breaking Changes |
| 6 | + |
| 7 | +#### Upgrade to Sundials v7 |
| 8 | + |
| 9 | +This release updates the underlying Sundials C library from v5 to v7, which introduces significant API changes. This is a **breaking change** for users directly using the low-level Sundials API. |
| 10 | + |
| 11 | +**Key Changes:** |
| 12 | + |
| 13 | +1. **SUNContext requirement**: All Sundials objects now require a `SUNContext` object for creation. This context manages the Sundials environment and must be created before any solver objects. |
| 14 | + |
| 15 | +2. **Memory management**: The new context-based approach improves thread safety and resource management. |
| 16 | + |
| 17 | +**Migration Guide for Low-Level API Users:** |
| 18 | + |
| 19 | +If you're using the low-level Sundials API directly (not through the DiffEq interface): |
| 20 | + |
| 21 | +```julia |
| 22 | +# Old code (v4.x) - No context needed |
| 23 | +mem_ptr = CVodeCreate(CV_BDF) |
| 24 | +mem = Handle(mem_ptr) |
| 25 | +``` |
| 26 | + |
| 27 | +```julia |
| 28 | +# New code (v5.0) - Context required |
| 29 | +ctx_ptr = Ref{SUNContext}(C_NULL) |
| 30 | +SUNContext_Create(C_NULL, Base.unsafe_convert(Ptr{SUNContext}, ctx_ptr)) |
| 31 | +ctx = ctx_ptr[] |
| 32 | +mem_ptr = CVodeCreate(CV_BDF, ctx) # Context passed as argument |
| 33 | +mem = Handle(mem_ptr) |
| 34 | +# ... use solver ... |
| 35 | +SUNContext_Free(ctx) # Clean up context when done |
| 36 | +``` |
| 37 | + |
| 38 | +**Automatic handling in high-level interface:** |
| 39 | + |
| 40 | +If you're using the standard DiffEq interface (`solve(prob, CVODE_BDF())`), **no changes are needed**. The context is automatically managed internally: |
| 41 | + |
| 42 | +```julia |
| 43 | +# This continues to work without changes |
| 44 | +sol = solve(prob, CVODE_BDF()) |
| 45 | +``` |
| 46 | + |
| 47 | +**Functions affected by context requirement:** |
| 48 | +- All solver creation functions (`CVodeCreate`, `ARKStepCreate`, `IDACreate`, `KINCreate`) |
| 49 | +- All vector creation functions (`N_VNew_Serial`, etc.) |
| 50 | +- All matrix creation functions (`SUNDenseMatrix`, `SUNBandMatrix`, etc.) |
| 51 | +- All linear solver creation functions (`SUNLinSol_Dense`, etc.) |
| 52 | + |
| 53 | +The context is automatically freed when the integrator is garbage collected through the `ContextHandle` mechanism. |
| 54 | + |
| 55 | +#### DAE Initialization Algorithm Changes |
| 56 | + |
| 57 | +The default initialization behavior for DAE problems has changed significantly. This is a **breaking change** that may affect existing code using IDA. |
| 58 | + |
| 59 | +**Previous behavior:** |
| 60 | +- IDA would automatically attempt to compute consistent initial conditions by default |
| 61 | +- This automatic initialization could sometimes produce incorrect results without warning |
| 62 | + |
| 63 | +**New behavior:** |
| 64 | +- The default is now validation-only mode that checks if provided initial conditions are consistent |
| 65 | +- If initial conditions are inconsistent, an error is raised with a clear message |
| 66 | +- Automatic initialization must be explicitly requested |
| 67 | + |
| 68 | +**Migration Guide:** |
| 69 | + |
| 70 | +If you have existing code that relies on automatic DAE initialization: |
| 71 | + |
| 72 | +```julia |
| 73 | +# Old code (v4.x) - automatic initialization was implicit |
| 74 | +prob = DAEProblem(f, du0, u0, tspan, differential_vars = differential_vars) |
| 75 | +sol = solve(prob, IDA()) |
| 76 | +``` |
| 77 | + |
| 78 | +You now have several options: |
| 79 | + |
| 80 | +1. **Use automatic initialization explicitly (recommended for most users):** |
| 81 | +```julia |
| 82 | +using DiffEqBase: BrownFullBasicInit |
| 83 | +prob = DAEProblem(f, du0, u0, tspan, differential_vars = differential_vars) |
| 84 | +sol = solve(prob, IDA(), initializealg = BrownFullBasicInit()) |
| 85 | +``` |
| 86 | + |
| 87 | +2. **Provide consistent initial conditions:** |
| 88 | +```julia |
| 89 | +# Ensure du0 and u0 satisfy f(du0, u0, p, t0) = 0 |
| 90 | +prob = DAEProblem(f, du0, u0, tspan, differential_vars = differential_vars) |
| 91 | +sol = solve(prob, IDA()) # Will validate and proceed if consistent |
| 92 | +``` |
| 93 | + |
| 94 | +3. **For problems without differential_vars information:** |
| 95 | +```julia |
| 96 | +using DiffEqBase: ShampineCollocationInit |
| 97 | +prob = DAEProblem(f, du0, u0, tspan) # No differential_vars |
| 98 | +sol = solve(prob, IDA(), initializealg = ShampineCollocationInit()) |
| 99 | +``` |
| 100 | + |
| 101 | +**Available initialization algorithms:** |
| 102 | +- `DefaultInit()` - Intelligently chooses initialization based on problem type (new default) |
| 103 | +- `BrownFullBasicInit()` - Brown's algorithm for index-1 DAEs (requires differential_vars) |
| 104 | +- `ShampineCollocationInit()` - Shampine's collocation method (works without differential_vars) |
| 105 | +- `CheckInit()` - Only validates initial conditions without modification |
| 106 | + |
| 107 | +**Why this change was made:** |
| 108 | +- **Safety**: Silent automatic initialization could produce incorrect results |
| 109 | +- **Clarity**: Users now explicitly choose their initialization strategy |
| 110 | +- **Debugging**: Clearer error messages when initial conditions are inconsistent |
| 111 | +- **Performance**: Avoid unnecessary initialization computations when not needed |
| 112 | + |
| 113 | +#### ModelingToolkit Initialization Support |
| 114 | + |
| 115 | +CVODE and ARKODE now support the `initializealg` parameter for parameter initialization compatibility with ModelingToolkit. This enables proper handling of problems with initialization requirements. |
| 116 | + |
| 117 | +```julia |
| 118 | +# Now supported for ODE problems with initialization needs |
| 119 | +sol = solve(prob, CVODE_BDF()) # , initializealg = SciMLBase.OverrideInit()) done by default |
| 120 | +``` |
| 121 | + |
| 122 | +### Features |
| 123 | + |
| 124 | +- Added support for DiffEqBase initialization algorithms across all Sundials solvers |
| 125 | +- Improved callback handling to use callback-specific initialization algorithms |
| 126 | +- Enhanced error messages for DAE initialization failures |
| 127 | + |
| 128 | +### Dependency Updates |
| 129 | + |
| 130 | +- **Sundials_jll**: Updated from v5.x to v7.4.1 (major version bump) |
| 131 | +- Minimum DiffEqBase version: 6.190.2 |
| 132 | +- Added NonlinearSolveBase dependency for improved nonlinear solving |
| 133 | +- Added LinearSolve dependency for initialization support |
| 134 | +- Updated minimum SciMLBase version to 2.119.0 |
0 commit comments