hiddenSymmetries / simsopt

Simons Stellarator Optimizer Code
https://simsopt.readthedocs.io
MIT License
83 stars 43 forks source link

spec.spec_f90wrapped is missing #422

Closed cctutum closed 3 weeks ago

cctutum commented 1 month ago

I have just installed simsopt using pip install simsopt on a fresh conda environment and am on main branch (version 1.3.0).

I am trying to run the SPEC example in the "Optimizing an equilibrium code" (https://simsopt.readthedocs.io/en/latest/example_vmec_only.html).

When I come to this line: equil = Spec('2DOF_targetIotaAndVolume.sp')

I am getting the following error:

File ~/anaconda3/envs/SIMSOPT/lib/python3.11/site-packages/simsopt/mhd/spec.py:100, in Spec.__init__(self, filename, mpi, verbose, keep_all_files, tolerance)
     92 def __init__(self,
     93              filename: Optional[str] = None,
     94              mpi: Optional[MpiPartition] = None,
     95              verbose: bool = True,
     96              keep_all_files: bool = False,
     97              tolerance: float = 1e-12):
     99     if spec is None:
--> 100         raise RuntimeError(
    101             "Using Spec requires spec python wrapper to be installed.")
    102     if py_spec is None:
    103         raise RuntimeError(
    104             "Using Spec requires py_spec to be installed.")

spec is None because when spec.py in ~/anaconda3/envs/SIMSOPT/lib/python3.11/site-packages/simsopt/mhd is called, it runs this (Lines=25-29):

try:
    import spec.spec_f90wrapped as spec
except ImportError as e:
    spec = None
    logger.debug(str(e))

However, it cannot find spec_f90wrapped which is a Fortran module that is wrapped for Python using f2py (specifically, Numpy). I have numpy version 1.26.4.

How can I get this fortran wrapper installed in the mhd folder?

landreman commented 1 month ago

Hi, have you built and installed spec and the python wrapper for it, from https://github.com/PrincetonUniversity/SPEC? Installing simsopt does not automatically install spec. It looks like there are some instructions for spec here

cctutum commented 1 month ago

Thank you very much for the quick reply. I haven't installed it separately and will check it out!

smiet commented 3 weeks ago

Hi @cctutum, I can help with getting SPEC installed. Contact me if you need, for now closing the issue.