Skip to content

Commit dace2f1

Browse files
committed
Updated the instructions for compilation using cmake
1 parent 2dc8406 commit dace2f1

4 files changed

+113
-45
lines changed

compilation_instructions.md

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
## SPEC complition instructions
2+
3+
Guide for installing SPEC including the python wrappers, relies on usign cmake
4+
5+
### Compilation
6+
7+
Get the repository and install the necessary compilers and libraries
8+
```
9+
git clone [email protected]:PrincetonUniversity/SPEC.git
10+
conda create -n "spec_wrapper" python=3.11
11+
conda activate spec_wrapper
12+
conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64
13+
conda install hdf5 openblas libopenblas fftw scalapack openmpi cmake ninja
14+
conda install h5py matplotlib f90nml scipy scikit-build mpi4py ipython
15+
pip install f90wrap
16+
```
17+
18+
Link to the correct `f2py`
19+
```
20+
ln -s ~/anaconda3/envs/spec_wrapper/bin/f2py ~/anaconda3/envs/spec_wrapper/bin/f2py3
21+
```
22+
23+
If necessary, unset HDF5 and FFTW environmental variables
24+
```
25+
unset HDF5, HDF5_ROOT, HDF5_HOME, FFTW, FFTW_DIR
26+
```
27+
28+
Finally, install SPEC and the wrapper (logs will be in `compile.log`)
29+
```
30+
pip install -v . 2>&1 | tee compile.log
31+
```
32+
33+
Install the `py_spec` python library
34+
```
35+
cd Utilities/pythontools/
36+
pip install -e .
37+
```
38+
39+
40+
### Testing your SPEC installation
41+
42+
First, verify that the stand-alone executable is usable.
43+
A few test cases are provided in `InputFiles/TestCases`.
44+
45+
Create a new directory for SPEC runs and change into it
46+
47+
```bash
48+
mkdir ~/SPEC_runs
49+
cd ~/SPEC_runs
50+
```
51+
52+
Copy a demo input file into the current working directory:
53+
54+
```bash
55+
cp ~/SPEC/InputFiles/TestCases/G3V01L0Fi.001.sp .
56+
```
57+
58+
Call SPEC with an input file (`*.sp`) as argument on the command line:
59+
60+
```bash
61+
xspec G3V01L0Fi.001.sp
62+
```
63+
64+
You should see the screen output of the SPEC run.
65+
Among the last lines should be something similar to this:
66+
67+
```
68+
ending : 0.88 : myid= 0 ; completion ; time= 0.88s = 0.01m = 0.00h = 0.00d ; date= 2022/02/17 ; time= 17:35:33 ; ext = G1V02L0Fi.001
69+
ending : :
70+
xspech : :
71+
xspech : 0.88 : myid= 0 : time= 0.01m = 0.00h = 0.00d ;
72+
```
73+
74+
This indicates that the stand-alone executable is usable.
75+
76+
Next, the python wrapper is tested.
77+
78+
1. Check that the SPEC version can be found:
79+
80+
```bash
81+
python -c "from spec import spec_f90wrapped as spec; print('SPEC version: {:}'.format(spec.constants.version))"
82+
```
83+
84+
This should print a message like "SPEC version: 3.1" on the screen.
85+
86+
2. Check that the Python wrapper can be used as a stand-alone code:
87+
88+
```bash
89+
OMP_NUM_THREADS=1 python ~/SPEC/Utilities/python_wrapper/spec/core.py G3V01L0Fi.001.sp
90+
```
91+
92+
This should conclude with the message `SPEC called from python finished!`.
93+
94+
3. Run the optimization example code:
95+
96+
```bash
97+
OMP_NUM_THREADS=1 python ~/SPEC/Utilities/python_wrapper/examples/example.py
98+
```
99+
100+
This should run a basic optimization problem,
101+
where the SPEC inputs are controlled via `scipy.optimize`.
102+
103+
4. Run the interactive re-convergence example code:
104+
105+
```bash
106+
OMP_NUM_THREADS=1 python ~/SPEC/Utilities/python_wrapper/examples/example_2.py
107+
```
108+
109+
This should compute a SPEC equilibrium, then change the central pressure,
110+
re-converge SPEC, etc. for a set of five values of the central pressure
111+
in a two-volume classical Stellarator case.
112+
After the pressure scan with re-convergence,
113+
a plot of the MHD energy vs. the central pressure is shown.
File renamed without changes.

setup_conda.sh

-26
This file was deleted.

spec_conda_env.yml

-19
This file was deleted.

0 commit comments

Comments
 (0)