docs(readme): updated readme

This commit is contained in:
2025-06-13 09:41:23 -04:00
parent 9de818dd5b
commit 92270e72fe

View File

@@ -109,6 +109,75 @@ If you want to run tests
meson test -C build
```
### Installing the python module
SERiF also provides a python interface. At the moment this is somewhat limited; however, we intend that it will eventually provide a full interface to the code. Installation
is very easy and requires the same dependencies as the C++ code. From the root SERiF directory you can use pip to install the `serif` module.
```bash
pip install .
```
This will take *a long time* to run since this process configures, compiles, and links the entire C++ code base every time it is run.
If you are developing the python interface it makes more sense to use incremental builds. To do this you can a few `pip` flags
```bash
pip install -e . --no-build-isolation --vv
```
The first time you run this it will take just as long, but subsequent runs will be much faster.
## Python Usage
Once the `serif` module is installed it is pretty straigt forward to use. Eventually, this will be even easier as currently
we simply expose raw C++ functions and classes to python. This means that there is, at times, a bit of boilerplate needed.
### Some Examples
Using the EOS module is a good example of the kinds of boilerplate needed.
```python
from serif.eos import EOSInput
from serif.eos import get_helm_eos
from serif.eos import EOSio
eosfile = EOSio("./path/to/helm.dat")
helmTable = eosfile.getTable()
xmass = [0.75, 0.23, 0.02]
aion = [1.0, 4.0, 12.0]
zion = [1.0, 2.0, 6.0]
asum = 0
zsum = 0
for x, a, z in zip(xmass, aion, zion):
asum += x/a
zsum += (x*z)/a
q = EOSInput()
q.abar = 1.0/asum
q.zbar = q.abar * zsum
q.rho = 1.0e6
q.T = 1.0e8
r = get_helm_eos(q, helmTable);
print(r.ye, r.etot, r.sgas, ...)
```
> Note how the `serif` module does not currently have any ability to use the resource manager, and instead a path must be manually provided. Eventually, we will add a resource manager to the python interface which will allow for easier access to resources.
Solving a $n=1.5$ polytrope is another good example. This demonstrates the deep integration with the C++ code as well as our dependencies (like `MFEM`)
```python
from serif import config
from serif.polytrope import PolySolver
config.loadConfig('../../testsConfig.yaml')
n = config.get("Tests:Poly:Index", 0.0)
polytrope = PolySolver(n, 1)
polytrope.solve()
```
> **N.B.** This second example will only work on the tboudreaux/feature/pythonInterface/poly branch of the repository at the moment.
Note how simple this is to use, this is a _very_ explicit design goal. A few caveats here are that we have not currently implemented a way to actually access the solution other than to have GLVis running when you run this code.
## Test Configuration
Some tests use config variables setup in tests/testsConfig.yaml. Specifically for things like the GLVis host and port. You should configre those to point to whatever host you are running GLVis on.
@@ -194,7 +263,7 @@ But if a new developer wants somewhere to start, those are good places too.
| misc | WIP | This is a catch all module for misc things. Generally we should *avoid* putting stuff in here but sometimes (such as for debugging macros) it is useful. | N/A |
| network | MVS | This module handles the nuclear network and burning calculations. Currently only Frank Timmes' Approx8 network is implemented. It also implements a general interface for nuclear networks so that other networks can be added. | N/A |
| opac | WIP | This module handles opacity calculation / interpolation. | A.D. |
| poly | WIP | This module computes polytropic models which are used as initial states for solving the structure equations. | E.B. |
| polytrope | MVS | This module computes polytropic models which are used as initial states for solving the structure equations. | E.B. |
| probe | Complete | This module implements the `probe` namespace which is used to hold functions for probing the current state of the code (stuff like `whydt` in `MESA`) | N/A |
| python | WIP | This module contains all code relevant to the python interface. All interface code is then organized in submodules within this (such as python/config) | E.B. |
| resource | Complete | This module handles loading resource from disk in a clean fashion. The key justification here is to avoid users having to explicitly set environmental variables but also to make loading of resources any where in the code easer to handle | N/A |