Adding Symplectic Integrators#1411
Conversation
|
@JacobHass8 : I think a good test is to identify the conserved quantity you wish to be conserved, and show that quantity is much better preserved with a symplectic integrator than with (say) RK4. I would also recommend an API for event detection and return a solution skeleton that can be interpolated as a Hermite spline, i.e., return ${t_k, y_k, dot{y}k}{k=0}^{n-1}$ rather than the typical solution skeleton {t_k, y_k, }_{k=0}^{n-1}. |
I've tried this on a harmonic oscillator and the energy fluctuations seem to be of order 1e-11 (for the 6th order method). I haven't checked RK4 (or any other method though!).
I'm not sure I totally understand what you mean. Are you saying return a third object that could be used to interpolate between different |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1411 +/- ##
===========================================
- Coverage 95.39% 95.37% -0.02%
===========================================
Files 826 828 +2
Lines 68901 68976 +75
===========================================
+ Hits 65726 65787 +61
- Misses 3175 3189 +14
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Exactly. Say you have an However, you have to compute Note that this is still inferior to the "natural interpolant", but given there seems to be no hope to get every ODE stepper's interpolant into the standard graphics packages, I think this is a reasonable compromise. |
| namespace boost{ namespace math {namespace quadrature { | ||
|
|
||
| template <class RealType, class ReturnType, class Func> | ||
| std::pair<ReturnType, ReturnType> second_order_yoshida(const ReturnType p0, |
There was a problem hiding this comment.
@JacobHass8 : It appears to me that if we wanted to return both objects of the same type, we would do a std::array<ReturnType,2>. But it also appears that these two objects have different units. Could it work with dimensioned types like mpunitz or boost::units? That would indeed force you into a std::pair.
There was a problem hiding this comment.
I don't think the return object necessarily need to be the same type. It is just returning the input types of p0 and q0.
There was a problem hiding this comment.
However, there is a constraint on these types. Either we need to be able to add the types of p0 and q0 or we need the function dHdp to take in a type of p0 and return a type of q0 (for dHdq we need q0 -> p0).
This is because of the lines
ReturnType p = p0;
ReturnType q = q0;
q = q + dt / 2 * dHdp(p);
p = p - dt * dHdq(q);I'm not familiar with mpunitz or boost::units. I was only thinking about singletons versus array types.
| [ run test_trapezoidal.cpp /boost/test//boost_unit_test_framework : : : | ||
| release [ requires cxx11_lambdas cxx11_auto_declarations cxx11_decltype cxx11_unified_initialization_syntax cxx11_variadic_templates ] | ||
| $(float128_type) ] | ||
| [ run test_symplectic.cpp /boost/test//boost_unit_test_framework ] |
There was a problem hiding this comment.
I don't think you used boost unit test framework here right? You just used the boost::math floating point comparisons.
There was a problem hiding this comment.
I'm not entirely sure what the unit test framework is. I just copied it from test_trapezoidal...
|
@NAThompson I created a .qbk file to add documentation for the functions I added. I couldn't figure out how to build the documentation though. I kept getting errors when trying to follow the boost math guide. I wanted to include an equation so I created a .svg and .png using latex. However, I noticed that all other equations have a .mml file. Do you know how to convert these? |


Adds symplectic solvers for ODE systems with a conserved quantity (i.e. energy). This was a requested scipy feature (see #303 and scipy/scipy#12690). I'd ultimately like to merge this into scipy using cython. I'm still working on this and have a couple of features I'd like to add:
Does this seem like a good plan? I'd appreciate any input.