wrapper.c 1.88 KiB
#include "units_wrapper.h"
#include "part_wrapper.h"
#include "parser_wrapper.h"
#include "cooling_wrapper.h"
#include "pyswiftsim_tools.h"
#include "config_wrapper.h"
#include <Python.h>
#include <math.h>
#include <numpy/arrayobject.h>
/* definition of the method table */
static PyMethodDef wrapper_methods[] = {
{"partTestStruct", pypart_test_struct, METH_VARARGS,
"Construct a part object and return it."},
{"unitSystemTestStruct", pyunit_system_test_struct, METH_VARARGS,
"Construct a unit_system object and return it."},
{"parserReadFile", pyparser_read_file, METH_VARARGS,
"Read a swift params file."},
{"unitSystemInit", pyunit_system_init, METH_VARARGS,
"Construct a unit_system object and return it."},
{"coolingInit", pycooling_init, METH_VARARGS,
"Initialize cooling."},
{"coolingRate", pycooling_rate, METH_VARARGS,
"Compute the cooling rate.\n\n"
"Parameters\n"
"----------\n\n"
"pyconst: swift physical constant\n"
"pyus: swift unit system\n"
"cooling: swift cooling structure\n"
"rho: np.array\n"
"\t Mass density in pyus units\n"
"energy: np.array\n"
"\t Internal energy in pyus units\n"
"dt: float, optional\n"
"\t Time step in pyus units\n"
"fractions: np.array, optional\n"
"\t Fraction of each cooling element (including metals)\n"
},
{"configGetCooling", config_get_cooling, METH_VARARGS,
"Get the cooling type."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
static struct PyModuleDef wrapper_cmodule = {
PyModuleDef_HEAD_INIT,
"wrapper",
"Wrapper around the SPH cosmological simulation code SWIFT",
-1,
wrapper_methods
};
PyMODINIT_FUNC PyInit_wrapper(void)
{
PyObject *m;
/* set time for swift */
clocks_set_cpufreq(0);
import_array();
Py_Initialize();
m = PyModule_Create(&wrapper_cmodule);
if (m == NULL)
return NULL;
return m;
}