Use of C bindings. #70
|
First of all, sorry if this is off-topic or non sense, but I am trying to build a C program that uses CEA to solve a Rocket, expanding it a bit with C (ie. providing information like how much propellant would be actually needed). I've done some preliminary work using Excel and extracting data using cearun and Python so I know it's doable. It'd basically be a front end tho. I could follow the python examples but I have a few questions regarding a C implementation:
int main(){`
cea_string species[] = {"AL", "HCL", "H2O"};
cea_int nspecies = 3;
cea_mixture *mixture;
cea_init();
cea_mixture_create(mixture, nspecies, species);
cea_mixture_destroy(mixture);
return 0;
}
|
Replies: 1 comment 2 replies
|
This is definitely on-topic. Yes, using CEA as the computational core behind a C-based rocket front end is a reasonable thing to do. Python is not required here, it is just one of the available interfaces. On Your snippet is close, but the handle declaration is off. In real code, I would also check every On documentation: There is a C API reference in On whether CEA is “supported” for this use case: yes. Python is a convenience layer, not the only intended way to drive the library. If your surrounding application is already in C, using the C binding directly is a reasonable approach. On For rocket-specific work, the closest examples in-tree are the C RP-1311 rocket samples ( On similar projects: within this repo, the closest references are those C samples rather than a full standalone C front end. I’m not aware of a canonical larger C application in-tree built on top of the binding. If you want to share a rough sketch of the rocket workflow you want to drive from C, I can probably point you to the closest API path or sample. |
This is definitely on-topic.
Yes, using CEA as the computational core behind a C-based rocket front end is a reasonable thing to do. Python is not required here, it is just one of the available interfaces.
On
cea_init(): in the current implementation it performs process-wide initialization of the global thermo/transport databases. It is not a per-object allocation, and there is no publiccea_finalize()/shutdown function. The intended lifecycle is basically: callcea_init()once, create/destroy mixtures/solvers/solutions as needed, and let the process keep the global database state for its lifetime. So for a normal executable that is fine, but it is not a balanced init/shutdown API. Also, …