Variable NS_High in fastfarm.py is not computed correctly
Hello everyone,
In the past few days, I've been trying to setup a FAST.Farm case using this toolbox. However I had a domain issue which made my FAST.Farm simulations fail.
This error was:
T1:FARM_InitialCO:FWrap_t0:FAST_Solution0:CalcOutputs_And_SolveForInputs:SolveOption2:SolveOption2 c_Inp2AD_SrvD:InflowWind_CalcOutput:CalcOutput:IfW_4Dext_CalcOutput [position=(-2.3119, -0.17737, 151.57) in wind-file coordinates]:Interp4D:Outside the grid bounds.
After looking through the FAST.Farm documentation NS_high is computed as such, with S : X,Y,Z
NS\_High = CEILING\left(\frac{Sdist\_High}{DS\_High}\right)+1
While in the fastfarm.py file it is defined as such
nX_High = int(np.ceil(LX_High/dX_High))
nY_High = int(np.ceil(LY_High/dY_High))
nZ_High = int(np.ceil(LZ_High/dZ_High))
As you can see the +1 is missing. The moment I added it the FAST.Farm simulations started working.
Thanks you!
Thanks for your report. I'm surprised that FAST.Farm would crash: using a smaller nY,nZ should make the domain smaller, and therefore not exceed the dimension of the box. I must say I don't fully understand. But it seems true that the documentation requires a +1. We can certainly change the code to include that.
In #56, @rthedin is doing a rewrite of the case creation. Maybe he has a comment on it?
The choice of variable names is unfortunate here. The variables n{X,Y,Z}_High as you pasted above are the number of cells in each direction for the high-resolution boxes. That is not to be confused with the number of points, which is one more than the number of cells. The documentation gives the number of points:
- number of grid points in the high- and low-resolution domains (NS_High and NS_Low);
When creating the high-resolution boxes, we do use the number of grid points and add the +1 as given by the documentation: https://github.com/OpenFAST/python-toolbox/blob/5665bfb60dd2aec5dc198cfaa6cf423412532ded/pyFAST/fastfarm/fastfarm.py#L463-L465
Similarly, for the low-resolution box: https://github.com/OpenFAST/python-toolbox/blob/5665bfb60dd2aec5dc198cfaa6cf423412532ded/pyFAST/fastfarm/fastfarm.py#L435-L437
Two comments:
- I also find it surprising your change made the code work. That is only slightly changing the size of your boxes. I believe you might have some other inconsistencies in your setup. I recommend checking the velocity as seen by the turbine model with what you are giving as inflow (either TurbSim or LES). If the turbine is at a grid point, they should match exactly. That should give you a good sense if the turbine is indeed where you think it is and the boxes are laid on top of them as you think they are.
- As @ebranlard mentioned above, I recommend you use the new code related to the case creation (#56). We are actively working on that one and will be able to provide more support and fix bugs quicker.
Thank you for your comments. It appears it was confusion on my part and lucky coincidences. Although I have some questions.
-
How do I check such a thing?
-
I'll start using the branch then! Only one thing, after deleting the python-toolbox package, I cloned and tried to install the branch, however I get this error:
Defaulting to user installation because normal site-packages is not writeable Obtaining file:///home/Me/Desktop/Project/OpenFAST-python-toolbox Preparing metadata (setup.py) ... error error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [27 lines of output] /usr/lib/python3.10/site-packages/setuptools/dist.py:548: UserWarning: The version specified ('"0.1.0"') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details. warnings.warn( running egg_info Traceback (most recent call last): File "
", line 2, in File " ", line 34, in File "/home/Me/Desktop/Project/OpenFAST-python-toolbox/setup.py", line 17, in setup( File "/usr/lib/python3.10/site-packages/setuptools/init.py", line 108, in setup return distutils.core.setup(**attrs) File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 1213, in run_command super().run_command(command) File "/usr/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command cmd_obj.ensure_finalized() File "/usr/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized self.finalize_options() File "/usr/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 219, in finalize_options parsed_version = parse_version(self.egg_version) File "/usr/lib/python3.10/site-packages/packaging/version.py", line 197, in init raise InvalidVersion(f"Invalid version: '{version}'") packaging.version.InvalidVersion: Invalid version: '-0.1.0-' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed
× Encountered error while generating package metadata. ╰─> See above for output.
note: This is an issue with the package mentioned above, not pip. hint: See above for details.
A quick inspection shows that when you clone the branch the VERSION file comes with "0.1.0" written and if I change it to 3.3.0 as is in the branch it installs successfully. So I don't know what's going on there.
Thanks for your time!
Regarding 1. I think I managed to fix my inconsistencies and now its working properly.