Class ComplexODEConverter


  • public class ComplexODEConverter
    extends Object
    This class converts complex Ordinary Differential Equations into real ones.

    This class is a wrapper around a ComplexOrdinaryDifferentialEquation which allow to use a ODEIntegrator to integrate it.

    The transformation is done by changing the n dimension state vector to a 2n dimension vector, where the even components are real parts and odd components are imaginary parts.

    One should be aware that the data is duplicated during the transformation process and that for each call to computeDerivatives, this wrapper does copy 4n scalars : 2n before the call to computeDerivatives in order to dispatch the y state vector, and 2n after the call to gather zDot. Since the underlying problem by itself perhaps also needs to copy data and dispatch the arrays into domain objects, this has an impact on both memory and CPU usage. The only way to avoid this duplication is to perform the transformation at the problem level, i.e. to implement the problem as a first order one and then avoid using this class.

    The proper way to use the converter is as follows:

       ODEIntegrator                       integrator       = ...build some integrator...;
       ComplexOrdinaryDifferentialEquation complexEquations = ...set up the complex problem...;
       ComplexODEState                     initialState     = ...set up initial state...;
       ComplexODEConverter                 converter        = new ComplexODEConverter();
       ComplexODEStateAndDerivative        finalstate       =
          converter.convertStateAndDerivative(integrator.integrate(converter.convertEquations(complexEquations),
                                                                   converter.convertState(initialState),
                                                                   t);
     

    If there are complex secondary equations, they must be converted too and both the converted primary equations and converted secondary equations must be combined together using ExpandableODE as usual for regular real equations.

    Since:
    1.4
    See Also:
    ComplexOrdinaryDifferentialEquation, OrdinaryDifferentialEquation
    • Constructor Detail

      • ComplexODEConverter

        public ComplexODEConverter()
        Empty constructor.

        This constructor is not strictly necessary, but it prevents spurious javadoc warnings with JDK 18 and later.

        Since:
        3.0
    • Method Detail

      • convertSecondaryEquations

        public SecondaryODE convertSecondaryEquations​(ComplexSecondaryODE equations)
        Convert a secondary equations set.
        Parameters:
        equations - equations to convert
        Returns:
        converted equations
      • convertState

        public ODEState convertState​(ComplexODEState state)
        Convert a complex state (typically the initial state).
        Parameters:
        state - state to convert
        Returns:
        converted state
      • convertState

        public ComplexODEStateAndDerivative convertState​(ODEStateAndDerivative state)
        Convert a real state and derivatives (typically the final state or some intermediate state for step handling or event handling).
        Parameters:
        state - state to convert
        Returns:
        converted state