Skip to content

Init

Loic Hausammann requested to merge init into master

Initial version of PySWIFTsim.

@pdraper and @matthieu, if you want to review the code. I would like to suggest starting by tests/test_cooling.py to see how the wrapper works. If you want to run it, you will need to switch on the update_cooling_grackle branch in Swift and download this file https://bitbucket.org/grackle/grackle/src/4bfba7ac54e5d878f647f7686e517f47b7e1754e/input/CloudyData_UVB=HM2012.h5?at=default. For the setup, just run python setup.py install --with-swift PATH_TO_SWIFT.

You can then look at src/parser_wrapper, src/units_wrapper or src/cooling_wrapper (do not care about how I deal with the input/output, you will need to focus on it to understand it).

At the end, you can look at how I deal with the python/C interface. First you can look at pyswiftsim/structure.py where I define a python class for each struct that I am wrapping (using https://docs.python.org/3/library/struct.html) and then to src/pyswiftsim_tools where I define the C methods to transform a python object to a C object. The big advantage of my method is that you can modify any non pointer field (I would like to allow changing a pointer, but it may be tricky).

Edited by Loic Hausammann

Merge request reports