integration.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Internal header file for integration part of Dymosim FMI implementation. */
  2. /*
  3. All functions handle the case when the number of continuos states are 0, for convenience.
  4. */
  5. #ifndef integration_h
  6. #define integration_h
  7. #include "types.h"
  8. /* ----------------- function delcarations ----------------- */
  9. /**
  10. * Sets up integration.
  11. *
  12. * @param c the FMI component
  13. * @param relTol the relative tolerance, if non-positive, a default value is used
  14. * @return status
  15. */
  16. DYMOLA_STATIC IntegrationStatus integration_setup(FMIComponent c, FMIReal relTol);
  17. /**
  18. * Tears down integration. May be called also if comp or its iData pointer is NULL.
  19. *
  20. * @param c the FMI component
  21. */
  22. DYMOLA_STATIC void integration_teardown(FMIComponent c);
  23. /**
  24. * Integrates a time step forward. Time events are supposed to be handled outside
  25. * this function, i.e. h should be set not to pass those. Also step events shall
  26. * be handled outside. State events however are handled inside this function,
  27. * effectively re-initializing integration when needed.
  28. *
  29. * @param comp the FMI component
  30. * @param tout the end time
  31. * @return status
  32. */
  33. DYMOLA_STATIC IntegrationStatus integration_step(Component* comp, FMIReal tout);
  34. /* re-initialize integration due to events
  35. () */
  36. /**
  37. * Re-initialize the integration. Necessary at events.
  38. * In particular multistep methods will otherwise use obsolete derivatives.
  39. *
  40. * @param comp the FMI component
  41. * @return status
  42. */
  43. DYMOLA_STATIC IntegrationStatus integration_reinit(Component* comp);
  44. /**
  45. * Synchronizes the value used as a base for input extrapolation. This is necessary when input is updated
  46. * externally and in particular handles the case when input is set after the input derivatives.
  47. *
  48. * @param comp the FMI component
  49. * @param ix the index
  50. */
  51. DYMOLA_STATIC void integration_sync_extrapolation_input(Component* comp, size_t ix);
  52. /**
  53. * Updates the inputs according to input derivatives, if these are set recent enough.
  54. *
  55. * @param comp the FMI component
  56. * @param t the current time
  57. */
  58. DYMOLA_STATIC void integration_extrapolate_inputs(Component* comp, double t);
  59. #ifdef FMI_2
  60. /**
  61. * Gets the integration part of the FMU state.
  62. *
  63. * @param source the source
  64. * @param target the target
  65. * @return status
  66. */
  67. DYMOLA_STATIC FMIStatus integration_get_state(Component* source, Component* target);
  68. /**
  69. * Sets the integration part of the previously saved FMU state.
  70. *
  71. * @param source the source
  72. * @param target the target
  73. * @return status
  74. */
  75. DYMOLA_STATIC FMIStatus integration_set_state(Component* source, Component* target);
  76. /**
  77. * Frees the integration part of the previously saved FMU state.
  78. *
  79. * @param comp the FMI component to log status on
  80. * @param target the component to free
  81. */
  82. DYMOLA_STATIC void integration_free_state(Component* comp, Component* target);
  83. /**
  84. * Experimental function for HybridCosimulation
  85. *
  86. * @param tout is the propsed entime
  87. * @param tRet is the returned endTime
  88. */
  89. DYMOLA_STATIC IntegrationStatus integration_step_return_at_event(Component* comp, FMIReal tout, FMIReal* tRet);
  90. #endif /* FMI_2 */
  91. #endif /* integration_h */