WISDEM / CCBlade

A blade element momentum method for analyzing wind turbine aerodynamic performance that is robust (guaranteed convergence), fast (superlinear convergence rate), and smooth (continuously differentiable).
Other
43 stars 38 forks source link

CCBlade Installation #31

Open James-Ilosta opened 1 year ago

James-Ilosta commented 1 year ago

I'm trying to download CCBlade as a stand alone module. In the description it says that the only prerequisite is gfortran, however I also had to install GCC, meson and ninja too.

I wanted to install CCBlade inside a virtual environment, so I created one and began installation. When doing so it asked me to install meson, which I did. I then installed the GCC compiler and put it inside the virtual environment folder (I had some trouble with installing it and just adding it to the system path) Similarly with GFortran. It then asked me to install ninja, which I did. Following this I received the following error:

above ['C:\Users\user1\virtualenvironments\VENV1\Scripts\meson.EXE', 'setup', 'meson_build', '--prefix=C:\Users\user1\Downloads\CCBlade-master\CCBlade-master\meson_build', '-Dpython.purelibdir=.', '-Dpython.platlibdir=.'] below ['C:\Users\user1\virtualenvironments\VENV1\Scripts\meson.EXE', 'compile', '-vC', 'meson_build'] ninja: Entering directory `C:/Users/user1/Downloads/CCBlade-master/CCBlade-master/meson_build' [1/6] "C:\Users\user1\virtualenvironments\VENV1\Scripts\python.EXE" "-m" "numpy.f2py" "../ccblade/src/bem.f90" "-m" "_bem" "--lower" "--build-dir" "ccblade" Reading fortran codes... Reading file '../ccblade/src/bem.f90' (format:free) Post-processing... Block: _bem Block: inductionfactors In: :_bem:../ccblade/src/bem.f90:inductionfactors get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: relativewind In: :_bem:../ccblade/src/bem.f90:relativewind get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: definecurvature In: :_bem:../ccblade/src/bem.f90:definecurvature get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: windcomponents In: :_bem:../ccblade/src/bem.f90:windcomponents get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: thrusttorque In: :_bem:../ccblade/src/bem.f90:thrusttorque get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: inductionfactors_dv In: :_bem:../ccblade/src/bem.f90:inductionfactors_dv get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: relativewind_dv In: :_bem:../ccblade/src/bem.f90:relativewind_dv get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: windcomponents_dv In: :_bem:../ccblade/src/bem.f90:windcomponents_dv get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: definecurvature_dv In: :_bem:../ccblade/src/bem.f90:definecurvature_dv get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: thrusttorque_bv In: :_bem:../ccblade/src/bem.f90:thrusttorque_bv get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: definecurvature_bv In: :_bem:../ccblade/src/bem.f90:definecurvature_bv get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Block: definecurvature_dv2 In: :_bem:../ccblade/src/bem.f90:definecurvature_dv2 get_parameters: got "eval() arg 1 must be a string, bytes or code object" on 8 Applying post-processing hooks... character_backward_compatibility_hook Post-processing (stage 2)... Building modules... Building module "_bem"... Generating possibly empty wrappers" Maybe empty "_bem-f2pywrappers.f" Constructing wrapper function "inductionfactors"... fzero,a,ap = inductionfactors(r,chord,rhub,rtip,phi,cl,cd,b,vx,vy,[usecd,hubloss,tiploss,wakerotation]) Generating possibly empty wrappers" Maybe empty "_bem-f2pywrappers.f" Constructing wrapper function "relativewind"... alpha,w,re = relativewind(phi,a,ap,vx,vy,pitch,chord,theta,rho,mu) Generating possibly empty wrappers" Maybe empty "_bem-f2pywrappers.f" Constructing wrapper function "definecurvature"... x_az,y_az,z_az,cone,s = definecurvature(r,precurve,presweep,precone,[n]) Generating possibly empty wrappers" Maybe empty "_bem-f2pywrappers.f" Constructing wrapper function "windcomponents"... vx,vy = windcomponents(r,precurve,presweep,precone,yaw,tilt,azimuth,uinf,omegarpm,hubht,shearexp,[n]) Generating possibly empty wrappers" Maybe empty "_bem-f2pywrappers.f"

" I'm not familiar with fortran and so I'm not sure how to progress with the install. If you could provide any insight into what I'm doing wrong, This would be greatly appreciated.

gbarter commented 12 months ago

Apologies for the delay in reply. Also apologies that you are correct that the documentation is out of sync with the state of the code. I will update the README.

First, the easiest way to install CCBlade is to pip install wisdem or conda install wisdem (or mamba in place of conda).

If you want to continue building from source, can you let me know how you have installed the meson, ninja, gfortran, and gcc packages? Via conda or other means?

James-Ilosta commented 12 months ago

No worries.

I wasn't aware that you could simply use pip to install wisdem, as the documentation suggests using conda instead.

For installing meson and ninja i used pip. For downloading gcc and gfortran I used mingw64 to download gcc and gfortran, after which I moved it to my virtual environment root folder. Originally I had tried to add my mingw64 folder to path, but I couldn't seem to get my powershell terminal to recognise gcc or gfortran. I'm not that experienced in using mingw64 or downloading and installing programs in this way. So there is likely a better way to run ccblade without having to move the compilers to that folder.

gbarter commented 12 months ago

I am familiar with the struggle to get all of the PATH and ENVIRONMENT variables sorted out when using virtual environments and mingw64 on Windows. I have had success using Chocolatey as a Windows package manager instead.

It sounds like you found some workarounds to use CCBlade, but let me know if that isn't true. Yes, having WISDEM up on PyPi for pip-installs is a recent update and does simplify things.

James-Ilosta commented 12 months ago

I have tried installing WISDEM using pip and when running a script where ccblade is called I keep getting the following error:

Exception has occurred: ModuleNotFoundError (note: full exception trace is shown but execution is paused at: ) No module named 'wisdem.ccblade._bem' File "C:\Users\user1\Desktop\WISDEM\wisdem\ccblade\ccblade.py", line 32, in (Current frame) import wisdem.ccblade._bem as _bem File "C:\Users\user1\Desktop\WISDEM\wisdem\rotorse\rotor_power.py", line 16, in from wisdem.ccblade.ccblade import CCBlade, CCAirfoil File "C:\Users\user1\Desktop\WISDEM\wisdem\rotorse\rotor.py", line 4, in from wisdem.rotorse.rotor_power import RotorPower, NoStallConstraint File "C:\Users\user1\Desktop\WISDEM\wisdem\glue_code\glue_code.py", line 4, in from wisdem.rotorse.rotor import RotorSE File "C:\Users\user1\Desktop\WISDEM\wisdem\glue_code\runWISDEM.py", line 11, in from wisdem.glue_code.glue_code import WindPark File "C:\Users\user1\Desktop\WISDEM\wisdem__init__.py", line 1, in from wisdem.glue_code.runWISDEM import run_wisdem File "C:\Users\user1\Desktop\WISDEM\ROSCO_toolbox\utilities.py", line 30, in from wisdem.inputs import load_yaml File "C:\Users\user1\Desktop\WISDEM\ROSCO_toolbox\ofTools\fast_io\FAST_reader.py", line 8, in from ROSCO_toolbox.utilities import read_DISCON, load_from_txt File "C:\Users\user1\Desktop\WISDEM\script.py", line 20, in from ROSCO_toolbox.ofTools.fast_io.FAST_reader import * ModuleNotFoundError: No module named 'wisdem.ccblade._bem'

I've had this before and I can't seem to get past it. I've tried changing "wisdem.ccblade._bem" to the relative path to the script however I still can't seem to get it to work.

gbarter commented 11 months ago

I finally got onto a Windows machine and recreated the error using pip install wisdem. Looks like the compiled libraries were not getting built properly. I will do my best to fix them . . .

gbarter commented 11 months ago

After banging my head against the wall a number of times, I cannot get past this error on a pure pip-workflow in Windows. Everything works when using conda/mamba though and for Windows that might just have to be the recommended course of action. Apologies that I couldn't find the solution you were hoping for.

James-Ilosta commented 11 months ago

Hi Garrett. Thank you for trying. I really appreciate it. Is there a way to compile the libraries elsewhere and then simply move them to the pip module folder or when they are compiled, does is use environmental variables specified during the conda build? I'm really keen to use WISDEM inside my own virtual environment without needing conda, so I'm just wondering if there is another way.

gbarter commented 11 months ago

A compiled library will usually depend on some core system libraries, so it is a little tricky to compile in one environment on a specific platform and hope they will work elsewhere. On PyPI, we were uploaded a dozen or so different python-compiler-platform combinations. The benefit of Anaconda is that they tightly manage and control all of that for you.

ibrahim-hanif commented 3 weeks ago

I encountered a similar issue, which I recognized after installation and running the "unit tests" on the installation page (link) and couldn't solve it until a colleague reiterated that the fortran compiler should be installed without problems (from above link):

conda install -y m2w64-toolchain libpython       # (Windows only)
pip install --no-deps -e . -v

with this and going forward with the test, the error was solved and the test was run successfully, I hope. :)

(test_all.py output)

======================= 22 failed, 1285 passed, 13 skipped, 18122 warnings, 2 errors in 466.74s (0:07:46) =======================

Hope it is helpful.