CADET-Core icon indicating copy to clipboard operation
CADET-Core copied to clipboard

Implement missing CAPI methods

Open schmoelder opened this issue 3 years ago • 1 comments

Since PR #59 was closed prematurely, this is a continuation.

Original description: Adds a simple C interface to libcadet. The parameter provider interface is realized by callback functions. A simulation can be performed and the solution at the outlet of the unit operations can be queried.

Also includes a test application that dynamically loads the library at runtime (only Windows) and executes a simulation specified in JSON format internally.

This commit provides the first steps regarding #16 and, thus, #12.

To do:

  • [x] Inlet
  • [x] Outlet
  • [x] Bulk
  • [x] Particle
  • [x] Solid
  • [x] Flux
  • [x] Volume
  • [x] InletDot
  • [x] OutletDot
  • [x] BulkDot
  • [x] ParticleDot
  • [x] SolidDot
  • [x] FluxDot
  • [x] VolumeDot
  • [x] InletSens
  • [x] OutletSens
  • [x] BulkSens
  • [x] ParticleSens
  • [x] SolidSens
  • [x] FluxSens
  • [x] InletDotSens
  • [x] OutletDotSens
  • [x] BulkDotSens
  • [x] ParticleDotSens
  • [x] SolidDotSens
  • [x] FluxDotSens
  • [x] VolumeDotSens
  • [x] LastState
  • [x] LastStateTimeDot
  • [x] LastUnitState
  • [x] LastUnitStateDot
  • [x] LastSensitivityState
  • [x] LastSensitivityStateDot
  • [x] LastSensitivityUnitState
  • [x] LastSensitivityUnitStateDot
  • [x] Coordinates
  • [x] SolutionTimes

Moreover, some things are still unclear / inconsitent

  • On unit operation level, WRITE_SOLUTION_LAST_UNIT could be renamed to WRITE_SOLUTION_LAST. I don't think anyone is using this feature yet so a breaking change is justifiable in my opinion.
  • WRITE_SOLDOT_LAST(_UNIT) is completely missing; at least in the documentation. Check if it works.
  • Same for WRITE_SENS_LAST(_UNIT) and WRITE_SENSDOT_LAST(_UNIT).
  • (Maybe) Rename LAST_STATE_SENSY_XXX => LAST_STATE_SENS_XXX, and LAST_STATE_SENSYDOT_XXX => LAST_STATE_SENSDOT_XXX (breaking change in output might break some stuff)
  • Currently, the order of dimensional arguments in the API is different from the order of the dimensions in the state vector. If possible, we should fix this to make it more consistent. I can foresee stupid implementation errors in the future... :see_no_evil:

schmoelder avatar Jul 11 '22 09:07 schmoelder

We implemented most of the methods but still need to test them (which we will do in tomorrow's Dev-Call). The reason why the test suite fails is probably because of the following:

https://github.com/modsim/CADET/blob/master/test/testCAPIv1.cpp#L3

So we need to modify the tests to make them OS independent.

schmoelder avatar Jul 24 '22 10:07 schmoelder

The file format is hardcoded in both the driver.hpp where the meta output is written and now also hardcoded (with value 040000) for the CAPI.

jbreue16 avatar Aug 16 '24 12:08 jbreue16

I don't understand the build issue with MacOS. If you have time, could you please have a look @sleweke?

schmoelder avatar Aug 19 '24 11:08 schmoelder

This PR is ready to be reviewed! :partying_face:

We test all unit operations using createLWE with different combinations of solution recorders (i.e. split_components=True/False etc) in CADET-Python and check that the simulation outputs have the correct shape. We could also consider adding such test in test/testCAPIv1.cpp but for now, it seems "good enough" to me. @jbreue16 and I also had some discussions about the parametrization of tests and that for system tests, we could also consider writing Python scrips as they are much easier to maintain and extend. If I'm not mistaken, that's also something he does for the convergence tests.

schmoelder avatar Aug 23 '24 12:08 schmoelder