"To do the exercises in this notebook, please `download:`download the wind file <wind_12_ms_TI_0.1.txt>` and `download:`download the results file <res_12_ms_TI_0.1.txt>`"
"To do the exercises in this notebook, please download the wind file and save it as ``wind_12_ms_TI_0.1.txt``: :download:`download file <wind_12_ms_TI_0.1.txt>`. You will also need the results file from the loading and plotting exercises."
]
},
{
...
...
%% Cell type:markdown id:fa60cf2d tags:
# Forced response and save to file
%% Cell type:raw id:7b072291 tags:
To do the exercises in this notebook, please `download:`download the wind file <wind_12_ms_TI_0.1.txt>` and `download:`download the results file <res_12_ms_TI_0.1.txt>`
To do the exercises in this notebook, please download the wind file and save it as ``wind_12_ms_TI_0.1.txt``: :download:`download file <wind_12_ms_TI_0.1.txt>`. You will also need the results file from the loading and plotting exercises.
%% Cell type:markdown id:fd77dbf1 tags:
It is now time to add the wind to our Turbie simulations.
where $C_T$ is constant from a simulation and calculated from a look-up table using the mean wind speed of a simulation, $U=\overline{u(t)}$. Furthermore, the forcing vector for our 2-DOF system is
1. Create a function that takes as input the path to a wind file and returns the time array and the wind array. Try it on the wind file. What is the wind speed at $t=1$ s?
2. Create a function that takes as input a wind array and returns the value for $C_T$ to be used in a simulation. Test it on the wind file.
3. Update your `dydt` function from the homogeneous response to include the aerodynamic forcing as defined above. What is the value of your new `dydt` function when $t=1$ and $y=[1, 2, 3, 4]$?
4. Use your numerical integrator, just like in the homogeneous response, to simulate Turbie's response with the following conditions.
* Time vector spans from 0 to 660 in spaces of 0.01 s.
5. Load the tower deflection from the results file. Plot the tower deflection in that file versus the tower deflection you just simulated. Do they match?
* Don't worry about the blade deflections matching -- the res file has a different coordinate system.
6. Save the results to a text file in a format similar to the results file we give you.
***Python hint**: Use `np.savetxt` with `delimiter='\t'` and `fmt='%.3f'` to get a nice file. You should also pass in a header string that explains the columns.
### Answers to the exercises
#### Exercise 1
%% Cell type:code id:305fdb38 tags:
``` python
importnumpyasnp
defload_wind(path):
"""Load the time and wind speed from a file.
Returns t, u.
"""
t_wind,wind=np.loadtxt(path,skiprows=1).T
returnt_wind,wind
# test the function
path='wind_12_ms_TI_0.1.txt'
t_test=1# time we want the wind speed
t_wind,wind=load_wind(path)# load the wind
idx_test=np.argmin(np.abs(t_wind-t_test))# index closest to t_test
print(wind[idx_test])# wind speed at that index
```
%% Cell type:markdown id:047090f9 tags:
#### Exercise 2
%% Cell type:code id:131be2c3 tags:
``` python
defcalculate_ct(u,ct_path='CT.txt'):
"""Calculate Ct using lookup table and wind
time series. ct = CT(U).
"""
u_mean=np.mean(u)# calculate mean of wind time series
"This is the final step before the final project!\n",
"\n",
"To do the exercises in this notebook, you will need the wind file from the forced response exercise and the results file from the loading and plotting exercise.\n",
"\n",
"### Exercises for the reader"
]
},
{
"cell_type": "raw",
"id": "3af72a2b",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"To do the exercises in this notebook, please `download:`download the wind file <wind_12_ms_TI_0.1.txt>`"
]
},
{
"cell_type": "markdown",
"id": "d272639b",
...
...
%% Cell type:markdown id:fa60cf2d tags:
# Bring it all together
This is the final step before the final project!
### Exercises for the reader
%% Cell type:raw id:3af72a2b tags:
To do the exercises in this notebook, you will need the wind file from the forced response exercise and the results file from the loading and plotting exercise.
To do the exercises in this notebook, please `download:`download the wind file <wind_12_ms_TI_0.1.txt>`
### Exercises for the reader
%% Cell type:markdown id:d272639b tags:
1. Write a function that:
* Takes as input:
* a path to a wind file,
* time to start simulating,
* time to stop simulating,
* time step, and
* a path to an output file to write,
* Simulates turbie's response to that wind, and
* Saves the simulation to a Turbie result file with the name given in the input.
2. Test this function on the wind file you can download at the top of this page and compare to your results for the forced response.
You can assume that the initial conditions are all zero.
That's it for the exercises! When you're done, you can take a shot at the final project. Have fun!