<jupyter_start><jupyter_text>FLOWUnsteady in Colab This notebook is an example of how to run [FLOWUnsteady](https://flow.byu.edu/FLOWUnsteady/) simulations on your Google Drive through Colab. It contains instructions for mounting Google Drive into the session, mounting the Julia kernel, and simple examples on how to run FLOWUnsteady and XFOIL. Prior to running this notebook, make sure you have created a new directory named `FLOWUnsteady` in your Google Drive (with the path `My Drive/FLOWUnsteady`), and that you have uploaded the files `dotjulia.tar.gz` and `naca0012.csv` into this folder. The folder should look like this:**NOTE:**  See [flow.byu.edu/FLOWUnsteady/tutorials/colab](https://flow.byu.edu/FLOWUnsteady/tutorials/aeroacoustics/) if you are missing any of these files.  Mounting Google Drive First, let's mount the Google Drive while we are still in the Python kernell. This will allow us to transfer files from this session and our Google Drive back and forth.Upon running it, this cell will ask you to link your Google Drive. Please follow the instructions. Once successfully done, your drive will be mounted under `/content/drive` (you can check that it was successfully mounted under the `Files` tab on the right panel).<jupyter_code>from google.colab import drive
drive.mount('/content/drive')<jupyter_output><empty_output><jupyter_text>Mounting Julia Kernel This cell installs Julia, associates PyCall with Python 2.7, installs the IJulia kernel for Jupyter, and mounts an image of all FLOW packages needed to run FLOWUnsteady. This process should take about 2 minutes.<jupyter_code># Installation cell
%%shell
if ! command -v julia 3>&1 > /dev/null
then
    echo '********************** Downloading Julia *****************************'
    wget 'https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.2-linux-x86_64.tar.gz' \
        -O /tmp/julia.tar.gz
    tar -x -f /tmp/julia.tar.gz -C /usr/local --strip-components 1
    rm /tmp/julia.tar.gz
fi
echo '********************** Setting up PyCall *********************************'
julia -e 'using Pkg; pkg"add PyCall;"; ENV["PYTHON"]="/usr/bin/python2"; pkg"build PyCall;"'

echo '********************** Setting up Julia Kernel on Jupyter ****************'
julia -e 'using Pkg; pkg"add IJulia;"'

echo '********************** Installing image of packages **********************'
tar -x --overwrite -f /content/drive/My\ Drive/FLOWUnsteady/dotjulia.tar.gz -C /root/.julia --strip-components 2

echo 'Done'<jupyter_output><empty_output><jupyter_text>Now, let's activate the Julia kernel by going to Colab's `Edit` menu and select `Notebook settings` from the drop down. Select *Julia 1.4* as the runtime (set `Hardware accelerator` to `none` since we don't need GPU capabilities).You should see something like this:Click on SAVE, and **we are ready to get going.** Verify that the Julia kernel was successfully installed and is running:<jupyter_code>println("You know we are running Julia if this cell runs sucessfully")<jupyter_output><empty_output><jupyter_text>Verify that PyCall was successfully set up with Python 2.7:<jupyter_code>import PyCall
PyCall.pyversion<jupyter_output><empty_output><jupyter_text>AirfoilPrep Example: Run XFOIL In this example we will use the FLOW package [AirfoilPrep](https://github.com/byuflowlab/AirfoilPrep.jl) to run XFOIL on a NACA 0012 (notice that this can be run on any arbitrary airfoil by simply changing the `airfoil_file` argument to any airfoil contour in your Google Drive)<jupyter_code>import AirfoilPrep
ap = AirfoilPrep

airfoil_file  = "/content/drive/My Drive/FLOWUnsteady/naca0012.csv"  # Airfoil contour to read
Re            = 10e6                       # Reynolds number
Ma            = 0.0                        # Mach number

# Read airfoil contour
x, y = ap.readcontour(airfoil_file; header_len=1, delim=",")

# Generate polar through XFOIL
polar = ap.runXFOIL(x, y, Re; alphas=[i for i in -30:1.0:30],
                              verbose=false, Mach=Ma,
                              iter=100)

# Plot polar
ap.plot(polar; geometry=true, cdpolar=false);<jupyter_output><empty_output><jupyter_text>The following cell saves $C_\ell$, $C_d$, and $C_m$ vs angle of attack in a csv file at the indicated location in your Google Drive (go to your Google Drive and verify that the file `naca0012_polar.csv` has been created. You may need to refresh your browser).<jupyter_code>ap.save_polar2(polar, "naca0012_polar.csv"; path="/content/drive/My Drive/FLOWUnsteady/")
println("Done!")<jupyter_output><empty_output><jupyter_text>FLOWUnsteady Example: Tandem Heaving Wing In this example we run the tandem heaving wing example of FLOWUnsteady that comes with the package. We can't do any visualization in this notebook, but here is a video of what the simulation looks like:<jupyter_code>#@title .
using PyCall
command1 = "<iframe width=\"600\" height=\"337\" src=\"https://www.youtube.com/embed/"
command2 = "?modestbranding=1&autohide=1&showinfo=0&rel=0&controls=1\"
            frameborder=\"0\" allow=\"autoplay; encrypted-media\" 
            allowfullscreen></iframe>"
HTML(command1*"Pch94bKpjrQ"*command2)<jupyter_output><empty_output><jupyter_text>**NOTE 1:** In order to visualize the simulation, you can move the vtk files under `tandemheaving-example/` (generated by the simulation) out of Colab and into your own computer, and open them with Paraview.**NOTE 2:** For more information on FLOWUnsteady, check the documentation ([flow.byu.edu/FLOWUnsteady](https://flow.byu.edu/FLOWUnsteady/)).<jupyter_code>import FLOWUnsteady

# Path to examples folder
path_to_examples = joinpath(dirname(pathof(FLOWUnsteady)), "..", "examples")

# Include tandem heaving wing example
include(joinpath(path_to_examples, "tandemheavingwing.jl"))

# Run tandem heaving wing example
tandemheavingwing(; VehicleType=FLOWUnsteady.UVLMVehicle,
                    save_path="tandemheaving-example/");<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12479005710446758, 'fraction_numerical': 0.013436345314074572, 'mean_word_length': 4.687679083094556, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, 'https://': 6, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '116662', 'license': 'MIT', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1817, 'n_words': 624, 'path': 'docs/resources/colab/FLOWUnsteady-example.ipynb', 'repo_name': 'Bossgb97/check', 'size': '5954'}