diff --git a/binder/notebooks/Flapping Wings.ipynb b/binder/notebooks/Flapping Wings.ipynb new file mode 100644 index 0000000..a0d75cf --- /dev/null +++ b/binder/notebooks/Flapping Wings.ipynb @@ -0,0 +1,929 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "using PotentialFlow" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "using Plots\n", + "\n", + "clibrary(:colorbrewer)\n", + "default(clim = (-0.05, 0.05), markerstrokealpha = 0, markersize = 3, grid = false, \n", + " legend = false, colorbar = :right, colorbar_title = \"\\$\\\\Gamma\\$\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up Functions for Potential Flow Constraints" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "compute_ẋ! (generic function with 1 method)" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function compute_ẋ!(ẋ, x, t)\n", + " plate, ambient_sys = x\n", + " motion = ẋ[1]\n", + " motion.ċ, motion.c̈, motion.α̇ = motion.kin(t)\n", + " \n", + " Plates.enforce_no_flow_through!(plate, motion, ambient_sys, t)\n", + " reset_velocity!(ẋ, x)\n", + " self_induce_velocity!(ẋ, x, t)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "shed_new_vorticity! (generic function with 3 methods)" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function shed_new_vorticity!(blobs, plate, motion, t, lesp = 0.0, tesp = 0.0)\n", + " z₊ = (blobs[end-1].z + 2plate.zs[end])/3\n", + " z₋ = (blobs[end].z + 2plate.zs[1])/3\n", + " \n", + " blob₊ = Vortex.Blob(z₊, 1.0, δ)\n", + " blob₋ = Vortex.Blob(z₋, 1.0, δ)\n", + " Plates.enforce_no_flow_through!(plate, motion, blobs, t)\n", + " \n", + " Γ₊, Γ₋, _, _ = Plates.vorticity_flux!(plate, blob₊, blob₋, t, lesp, tesp);\n", + " \n", + " push!(blobs, Vortex.Blob(z₊, Γ₊, blobs[1].δ), Vortex.Blob(z₋, Γ₋, blobs[1].δ))\n", + "end" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up Kinematics Functions\n", + "\n", + "### See Viscous Flow examples for how to switch between square/triangle waves and sinusoidal pitch-heaving flapping motions" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "struct TriangleWave <: RigidBodyMotions.Profile\n", + " w::Float64\n", + " round_factor::Float64\n", + "end\n", + "\n", + "(T::TriangleWave)(t) = 1/(1-2/pi*acos(1-T.round_factor))*(1-2/pi*acos((1-T.round_factor)*sin(T.w*t - pi/2)))" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "struct SquareWave <: RigidBodyMotions.Profile\n", + " w::Float64\n", + " round_factor::Float64\n", + "end\n", + "\n", + "(s::SquareWave)(t) = 1/atan(1/s.round_factor)*atan(sin(s.w*t)/s.round_factor)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "struct PitchHeaveTest <: Kinematics\n", + " \"Freestream velocity\"\n", + " U₀::Float64\n", + "\n", + " \"Axis of pitch rotation, relative to the plate centroid\"\n", + " a::Float64\n", + "\n", + " \"Reduced frequency ``K = \\\\frac{\\\\Omega c}{2U_0}``\"\n", + " K::Float64\n", + "\n", + " \"Phase lag of pitch to heave (in radians)\"\n", + " ϕ::Float64\n", + "\n", + " \"Mean angle of attack\"\n", + " α₀::Float64\n", + "\n", + " \"Amplitude of pitching\"\n", + " Δα::Float64\n", + "\n", + " \"Amplitude of translational heaving\"\n", + " A::Float64\n", + " \n", + " \"Sinusoidal nature of pitching/heaving\"\n", + " delta_pitch::Float64\n", + " delta_heave::Float64\n", + "\n", + " Y::RigidBodyMotions.Profile\n", + " Ẏ::RigidBodyMotions.Profile\n", + " Ÿ::RigidBodyMotions.Profile\n", + "\n", + " α::RigidBodyMotions.Profile\n", + " α̇::RigidBodyMotions.Profile\n", + " α̈::RigidBodyMotions.Profile\n", + " \n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "PitchHeaveTest" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function PitchHeaveTest(U₀, a, K, ϕ, α₀, α_start, Δα, A)\n", + " p = A*RigidBodyMotions.Sinusoid(2K)\n", + " ṗ = d_dt(p)\n", + " p̈ = d_dt(ṗ)\n", + " α = RigidBodyMotions.ConstantProfile(α₀) + Δα*(RigidBodyMotions.Sinusoid(2K) >> (ϕ/(2K))) + RigidBodyMotions.ConstantProfile(α_start)\n", + " α̇ = d_dt(α)\n", + " α̈ = d_dt(α̇)\n", + " PitchHeaveTest(U₀, a, K, ϕ, α₀, Δα, A, 1, 1, p, ṗ, p̈, α, α̇, α̈)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "PitchHeaveTest" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "function PitchHeaveTest(U₀, a, K, ϕ, α₀, α_start, Δα, A, delta_pitch, delta_heave)\n", + " p = A*TriangleWave(2K, delta_heave)\n", + " ṗ = d_dt(p)\n", + " p̈ = d_dt(ṗ)\n", + " α = RigidBodyMotions.ConstantProfile(α₀) + Δα*(SquareWave(2K, delta_pitch) >> (ϕ/(2K))) + RigidBodyMotions.ConstantProfile(α_start)\n", + " α̇ = d_dt(α)\n", + " α̈ = d_dt(α̇)\n", + " PitchHeaveTest(U₀, a, K, ϕ, α₀, Δα, A, delta_pitch, delta_heave, p, ṗ, p̈, α, α̇, α̈)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "function (p::PitchHeaveTest)(t)\n", + " α = p.α(t)\n", + " α̇ = p.α̇(t)\n", + " α̈ = p.α̈(t)\n", + "\n", + " c = p.U₀*t + im*p.Y(t) - p.a*exp(im*α)\n", + " ċ = p.U₀ + im*p.Ẏ(t) - p.a*im*α*exp(im*α)*α̇ \n", + " c̈ = im*p.Ÿ(t) - p.a*im*α̇ *exp(im*α)*α̇ + p.a*α^2*exp(im*α)*α̇ ^2 - p.a*im*α*exp(im*α)*α̈ \n", + "\n", + " # return c, ċ, c̈, α, α̇, α̈\n", + " return ċ, c̈, α̇, α̈ # to work out with RigidBodyMotions in Potential Flow, edit if this doesn't work\n", + " \n", + "end" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setting Up Body, Environment, and Solver" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Rigid Body Motion:\n", + " ċ = 0.0 + 1.57im\n", + " c̈ = -0.68 + 1.17im\n", + " α̇ = 0.0\n", + " α̈ = -5.17\n", + " PitchHeaveTest(0.0, 0.5, 1.5707963267948966, -1.5707963267948966, 0.0, 0.5235987755982988, 0.5, 1.0, 1.0, 0.5 × (Sinusoid (ω = 3.14)), d/dt (0.5 × (Sinusoid (ω = 3.14))), d/dt (d/dt (0.5 × (Sinusoid (ω = 3.14)))), AddedProfiles:\n", + " Constant (0.0)\n", + " 0.5235987755982988 × (Sinusoid (ω = 3.14) >> -0.5)\n", + " Constant (0)\n", + ", d/dt (AddedProfiles:\n", + " Constant (0.0)\n", + " 0.5235987755982988 × (Sinusoid (ω = 3.14) >> -0.5)\n", + " Constant (0)\n", + "), d/dt (d/dt (AddedProfiles:\n", + " Constant (0.0)\n", + " 0.5235987755982988 × (Sinusoid (ω = 3.14) >> -0.5)\n", + " Constant (0)\n", + ")))" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "U₀ = 0 # Translation velocity\n", + "a = 0.5 # Pitching axis (leading edge)\n", + "K = π*1.0/2 # Pitch rate\n", + "α₀ = 0.0 # Center Angle\n", + "α_start = 0; # Starting Angle\n", + "t₀ = 0.0 # Nominal starting time\n", + "Δα = π*30/180 # Total angle change\n", + "ϕ = -pi/2 # Phase lag between the triangle/square motions\n", + "A = 0.5 # amplitude/chord\n", + "\n", + "oscil = PitchHeaveTest(U₀,a,K,ϕ,α₀,α_start,Δα,A)\n", + "motion = RigidBodyMotion(oscil)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "PitchHeaveTest(0.0, 0.5, 1.5707963267948966, -1.5707963267948966, 0.0, 0.5235987755982988, 0.5, 1.0, 1.0, 0.5 × (Sinusoid (ω = 3.14)), d/dt (0.5 × (Sinusoid (ω = 3.14))), d/dt (d/dt (0.5 × (Sinusoid (ω = 3.14)))), AddedProfiles:\n", + " Constant (0.0)\n", + " 0.5235987755982988 × (Sinusoid (ω = 3.14) >> -0.5)\n", + " Constant (0)\n", + ", d/dt (AddedProfiles:\n", + " Constant (0.0)\n", + " 0.5235987755982988 × (Sinusoid (ω = 3.14) >> -0.5)\n", + " Constant (0)\n", + "), d/dt (d/dt (AddedProfiles:\n", + " Constant (0.0)\n", + " 0.5235987755982988 × (Sinusoid (ω = 3.14) >> -0.5)\n", + " Constant (0)\n", + ")))\n" + ] + } + ], + "source": [ + "N = 128\n", + "L = 1.0 # length of plate\n", + "println(oscil)\n", + "plate = Plate(N, L, zero(ComplexF64), oscil.α(0))\n", + "\n", + "Δt = 1e-2\n", + "\n", + "δ = 0.01\n", + "lesp = 0.6;\n", + "tesp = 0.0\n", + "\n", + "Δz₀ = im*3Δt*exp(im*plate.α)\n", + "z₋, z₊ = plate.zs[[1,N]]\n", + "\n", + "blobs = Vortex.Blob.(Δz₀ .+ [z₊, z₋], 1.0, δ)\n", + "\n", + "Plates.enforce_no_flow_through!(plate, motion, (), 0)\n", + "Γ₊, Γ₋, _, _ = Plates.vorticity_flux!(plate, blobs[1], blobs[2], 0.0, lesp, tesp);\n", + "\n", + "blobs = Vortex.Blob.(Δz₀ .+ [z₊, z₋], [Γ₊, Γ₋], δ)\n", + "\n", + "sys₀ = (plate, blobs)\n", + "\n", + "sys = deepcopy(sys₀)\n", + "sys₊ = deepcopy(sys₀) # Used for storage during time-marching\n", + "ẋs = (motion, allocate_velocity(blobs))\n", + "\n", + "forces = ComplexF64[];" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Running the Solver" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [], + "source": [ + "T = 0.0:Δt:10.0\n", + "\n", + "systems = Tuple{Plate,Array{PotentialFlow.Blobs.Blob{Float64},1}}[];\n", + "\n", + "for t in T\n", + " \n", + " plate, ambient_ω = sys\n", + " motion, ambient_u = ẋs\n", + "\n", + " resize!(sys₊[2], length(sys[2]))\n", + " forward_euler!(sys₊, sys, t, Δt, compute_ẋ!, advect!, ẋs)\n", + "\n", + " # The force requires information about the motion of the plate,\n", + " # the strength, location, and velocity of the ambient vortex elements,\n", + " # as well as the vorticity flux from the plate edges\n", + " push!(forces, Plates.force(plate, motion, ambient_ω, ambient_u,\n", + " (ambient_ω[end-1], ambient_ω[end]), Δt))\n", + "\n", + " sys, sys₊ = sys₊, sys\n", + " sys_new = deepcopy(sys)\n", + " push!(systems, sys_new)\n", + " \n", + " shed_new_vorticity!(sys[2], sys[1], ẋs[1], t, lesp, tesp)\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n", + "'latex' is not recognized as an internal or external command,\r\n", + "operable program or batch file.\r\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "┌ Info: Saved animation to \n", + "│ fn = C:\\Users\\nitin\\Documents\\PotentialFlow.jl-master\\PotentialFlow.jl-master\\binder\\notebooks\\flapping_wing_lesp0p6.gif\n", + "└ @ Plots C:\\Users\\nitin\\.julia\\packages\\Plots\\2KhB2\\src\\animation.jl:98\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n", + "latex: failed to create a dvi file\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"C:\\\\Users\\\\nitin\\\\Documents\\\\PotentialFlow.jl-master\\\\PotentialFlow.jl-master\\\\binder\\\\notebooks\\\\flapping_wing_lesp0p6.gif\")" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anim = @animate for i = 1:10:1001\n", + " plot(systems[i], color = :RdBu_r, ratio = 1, xlim=(-2.0, 2.0), ylim=(-2.5, 2.5))\n", + "end\n", + "gif(anim, \"flapping_wing_lesp0p6.gif\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plot(T, [-2real.(forces) 2imag.(forces)], layout = (2,1), linewidth = 2,\n", + " xlabel = \"Convective Time\", ylabel = [\"C_L\" \"C_D\"], ylim = (-25.0, 25.0))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Analyzing the System with Changes in Critical LESP\n", + "\n", + "#### The critical LESP value stays constant in each simulation, but we vary this constant value to find its effect on the forces acting on the plate." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0\n", + "0.1\n", + "0.2\n", + "0.3\n", + "0.4\n", + "0.5\n", + "0.6\n", + "0.7\n", + "0.8\n", + "0.9\n", + "1.0\n", + "1.1\n", + "1.2\n", + "1.3\n", + "1.4\n", + "1.5\n", + "1.6\n", + "1.7\n", + "1.8\n", + "1.9\n", + "2.0\n", + "2.1\n", + "2.2\n", + "2.3\n", + "2.4\n", + "2.5\n", + "2.6\n", + "2.7\n", + "2.8\n", + "2.9\n", + "3.0\n", + "3.1\n", + "3.2\n", + "3.3\n", + "3.4\n", + "3.5\n", + "3.6\n", + "3.7\n", + "3.8\n", + "3.9\n", + "4.0\n", + "4.1\n", + "4.2\n", + "4.3\n", + "4.4\n", + "4.5\n", + "4.6\n", + "4.7\n", + "4.8\n", + "4.9\n", + "5.0\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "┌ Info: Saved animation to \n", + "│ fn = C:\\Users\\nitin\\Documents\\PotentialFlow.jl-master\\PotentialFlow.jl-master\\binder\\notebooks\\forces_actual.gif\n", + "└ @ Plots C:\\Users\\nitin\\.julia\\packages\\Plots\\2KhB2\\src\\animation.jl:98\n" + ] + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "Plots.AnimatedGif(\"C:\\\\Users\\\\nitin\\\\Documents\\\\PotentialFlow.jl-master\\\\PotentialFlow.jl-master\\\\binder\\\\notebooks\\\\forces_actual.gif\")" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# DONT RUN THIS PART UNLESS YOUR REALLY WANT TO\n", + "\n", + "Δt = 0.01\n", + "T = 0.0:Δt:10.0\n", + "\n", + "\n", + "newanim = @animate for lesp = 0.0:0.1:5.0 # 0:0.01:2\n", + " \n", + " N = 128\n", + " L = 1.0 # length of plate\n", + " plate = Plate(N, L, zero(ComplexF64), oscil.α(0))\n", + "\n", + " δ = 0.01\n", + " tesp = 0.0\n", + "\n", + " Δz₀ = im*3Δt*exp(im*plate.α)\n", + " z₋, z₊ = plate.zs[[1,N]]\n", + " \n", + " blobs = Vortex.Blob.(Δz₀ .+ [z₊, z₋], 1.0, δ)\n", + " \n", + " println(lesp)\n", + "\n", + " Plates.enforce_no_flow_through!(plate, motion, (), 0)\n", + " Γ₊, Γ₋, _, _ = Plates.vorticity_flux!(plate, blobs[1], blobs[2], 0.0, lesp, tesp);\n", + "\n", + " blobs = Vortex.Blob.(Δz₀ .+ [z₊, z₋], [Γ₊, Γ₋], δ)\n", + "\n", + " sys₀ = (plate, blobs)\n", + "\n", + " sys = deepcopy(sys₀)\n", + " sys₊ = deepcopy(sys₀) # Used for storage during time-marching\n", + " ẋs = (motion, allocate_velocity(blobs))\n", + "\n", + " forces = ComplexF64[];\n", + " \n", + " systems = Tuple{Plate,Array{PotentialFlow.Blobs.Blob{Float64},1}}[];\n", + "\n", + " for t in T\n", + "\n", + " plate, ambient_ω = sys\n", + " motion, ambient_u = ẋs\n", + "\n", + " resize!(sys₊[2], length(sys[2]))\n", + " forward_euler!(sys₊, sys, t, Δt, compute_ẋ!, advect!, ẋs)\n", + "\n", + " # The force requires information about the motion of the plate,\n", + " # the strength, location, and velocity of the ambient vortex elements,\n", + " # as well as the vorticity flux from the plate edges\n", + " push!(forces, Plates.force(plate, motion, ambient_ω, ambient_u,\n", + " (ambient_ω[end-1], ambient_ω[end]), Δt))\n", + "\n", + " sys, sys₊ = sys₊, sys\n", + " sys_new = deepcopy(sys)\n", + " push!(systems, sys_new)\n", + "\n", + " shed_new_vorticity!(sys[2], sys[1], ẋs[1], t, lesp, tesp)\n", + " end\n", + " \n", + " plot(T, [-2real.(forces) 2imag.(forces)], layout = (2,1), linewidth = 2, xlim=(0.0, 11.0), ylim=(-50.0, 50.0),\n", + " xlabel = \"Convective Time\", ylabel = [\"C_D\" \"C_L\"])\n", + " \n", + "end\n", + "\n", + "gif(newanim, \"forces_actual.gif\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Julia 1.1.0", + "language": "julia", + "name": "julia-1.1" + }, + "language_info": { + "file_extension": ".jl", + "mimetype": "application/julia", + "name": "julia", + "version": "1.1.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}