# Writing binary bts files

Dear all,

in the last weeks I’ve been developing an alternative turbulent generator to TurbSim. For the time being, let’s assume that the time series are generated correctly. The goal would now be saving the 4D velocity matrix as a FAST-compatible .bts file. Threfore, I’ve been writing the following Matlab function:

[code]
fwrite(fid, 7, ‘int16’); % TurbSim format identifier (should = 7, just 'cause I like that number), INT(2)
fwrite(fid, WindFileStruct.Nz, ‘int32’); % the number of grid points vertically, INT(4)
fwrite(fid, WindFileStruct.Ny, ‘int32’); % the number of grid points laterally, INT(4)
fwrite(fid, 0, ‘int32’); % the number of tower points, INT(4)
fwrite(fid, WindFileStruct.N, ‘int32’); % the number of time steps, INT(4)

fwrite(fid, WindFileStruct.dz, ‘float32’); % grid spacing in vertical direction, REAL(4), in m
fwrite(fid, WindFileStruct.dy, ‘float32’); % grid spacing in lateral direction, REAL(4), in m
fwrite(fid, WindFileStruct.dt, ‘float32’); % grid spacing in delta time, REAL(4), in m/s
fwrite(fid, WindFileStruct.U0, ‘float32’); % the mean wind speed at hub height, REAL(4), in m/s
fwrite(fid, WindFileStruct.HubHt, ‘float32’); % height of the hub, REAL(4), in m
fwrite(fid, WindFileStruct.Zbottom, ‘float32’); % height of the bottom of the grid, REAL(4), in m

fwrite(fid, 1000, ‘float32’); % the U-component slope for scaling, REAL(4)
fwrite(fid, 0, ‘float32’); % the U-component offset for scaling, REAL(4)
fwrite(fid, 1000, ‘float32’); % the V-component slope for scaling, REAL(4)
fwrite(fid, 0, ‘float32’); % the V-component offset for scaling, REAL(4)
fwrite(fid, 1000, ‘float32’); % the W-component slope for scaling, REAL(4)
fwrite(fid, 0, ‘float32’); % the W-component offset for scaling, REAL(4)
fwrite(fid, l, ‘int32’); % the number of characters in the description string, max 200, INT(4)
for ii = 1:l
fwrite(fid, Version(ii), ‘int8’); % the ASCII integer representation of the character string
end

v = zeros(1,3);
cnt = 0;
for it = 1:WindFileStruct.N
for iz = 1:WindFileStruct.Nz
for iy = 1:WindFileStruct.Ny
for ii = 1:3
cnt = cnt + 1;
v(ii) = WindFileStruct.WF(it,iy,iz,ii)*1000;
end
fwrite(fid, v, ‘int16’);
end
end
end[/code]

What I’d like to undestand is the following: is the chunk related to time-series saving correct? If not, could you please point out how to successfully save the time series?

At the state of writing, I have performed to sets of simulations: the one set with standard TurbSim wind, the second set with my turbulent generator. When running a fatigue post-process, the damage equivalent loads stemming from my turbulent generator are always lower than those with TurbSim windfiles. Wind speed power spectra overlap perfectly though.
I’ve done something similar with Bladed, and equivalent loads were within a +/- 2% range.

I thank you for the support you will be showing me.

Best regards from Germany,
Francesco Perrone

Dear all,

I answer myself: until yesterday I’ve been assuming a Davenport coherence function also for the v- and w- components of the wind field.
Today I turned that off and moved to a TurbSim implementation, where v- and w- components are independent time series.
Now, when running a fatigue analysis, the difference between loads derived from FAST+TurbSim and FAST+FrancescoGenerator has actually decreased.
So I’d say that the “main” error source was assuming this coherence function.

In case of other possible uncertainty sources, please give me notice .

Kindest regards,
Francesco

Hi, Francesco.

Your code looks fine to me. We usually find the slope and intercept to allow for the maximum precision in our files, but using the values you’ve specified should be adequate for most cases.

Also, if you want TurbSim to use coherence in the v and w components, you can download an alpha version of TurbSim v2.0 here: nwtc.nrel.gov/alphas. This version gives you a little more flexibility for testing models.

Hallo Bonnie,