Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Variable NS_High in fastfarm.py is not computed correctly #62

Open
Ransses03 opened this issue Feb 16, 2023 · 4 comments
Open

Variable NS_High in fastfarm.py is not computed correctly #62

Ransses03 opened this issue Feb 16, 2023 · 4 comments

Comments

@Ransses03
Copy link

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!

@Ransses03 Ransses03 reopened this Feb 16, 2023
@ebranlard
Copy link
Collaborator

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?

@rthedin
Copy link
Collaborator

rthedin commented Feb 16, 2023

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:

x_high = X0_High[wt] + np.arange(nX_High+1)*dX_High
y_high = Y0_High[wt] + np.arange(nY_High+1)*dY_High
z_high = Z0_High[wt] + np.arange(nZ_High+1)*dZ_High

Similarly, for the low-resolution box:

x_low = fst['X0_Low'] + np.arange(fst['NX_Low']+1)*fst['DX_Low']
y_low = fst['Y0_Low'] + np.arange(fst['NY_Low']+1)*fst['DY_Low']
z_low = fst['Z0_Low'] + np.arange(fst['NZ_Low']+1)*fst['DZ_Low']

Two comments:

  1. 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.
  2. As @ebranlard mentioned above, I recommend you use the new code related to the case creation (FAST.Farm case creation class #56). We are actively working on that one and will be able to provide more support and fix bugs quicker.

@Ransses03
Copy link
Author

Thank you for your comments. It appears it was confusion on my part and lucky coincidences. Although I have some questions.

  1. How do I check such a thing?

  2. 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:https:///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!

@Ransses03
Copy link
Author

Regarding 1. I think I managed to fix my inconsistencies and now its working properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants