{ "cells": [ { "cell_type": "markdown", "source": [ "# Particle Cloud\n", "\n", "\n", "Using the same setup as `detailed_look.jl` or `example2()`, here we simulate\n", "a point cloud getting advected by the flow field.\n", "For additional documentation e.g. see :\n", "[1](https://JuliaClimate.github.io/IndividualDisplacements.jl/dev/),\n", "[2](https://JuliaClimate.github.io/MeshArrays.jl/dev/),\n", "[3](https://docs.juliadiffeq.org/latest/solvers/ode_solve.html),\n", "[4](https://en.wikipedia.org/wiki/Displacement_(vector))" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## 1. Import Software" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using IndividualDisplacements, Statistics\n", "\n", "import IndividualDisplacements.OrdinaryDiffEq: solve, Tsit5\n", "import IndividualDisplacements.DataFrames: DataFrame\n", "\n", "p=dirname(pathof(IndividualDisplacements))\n", "include(joinpath(p,\"../examples/more/example123.jl\"));" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "## 2. Setup Problem" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "𝑃,Γ=example2_setup()\n", "\n", "ii1=5:5:40; ii2=5:5:25\n", "x=vec([x-0.5 for x in ii1, y in ii2])\n", "y=vec([y-0.5 for x in ii1, y in ii2])\n", "xy = permutedims([[x[i];y[i];1.0] for i in eachindex(x)])\n", "\n", "solv(prob) = IndividualDisplacements.ensemble_solver(prob,solver=Tsit5(),reltol=1e-6,abstol=1e-6)\n", "tr = DataFrame(ID=Int[], x=Float64[], y=Float64[], t=Float64[])\n", "\n", "#𝐼 = Individuals{Float64,2}(📌=xy[:,:], 🔴=tr, 🆔=collect(1:size(xy,2))," ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ " 🚄 = dxdt!, ∫ = solv, 🔧 = postprocess_xy, 𝑃=𝑃);" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "I=(position=xy,record=deepcopy(tr),velocity=dxdt!,\n", " integration=solv,postprocessing=postprocess_xy,parameters=𝑃)\n", "𝐼=Individuals(I)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "## 3. Compute Trajectories" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "𝑇 = (0.0,2998*3600.0)\n", "∫!(𝐼,𝑇)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "## 4. Display results" ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Compare with trajectory output from `MITgcm`" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "#IndividualDisplacements.flt_example_download()\n", "#df=read_flt(IndividualDisplacements.flt_example_path,Float32)\n", "#ref=plot_paths(df,size(xy,2),100000.0)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.10.2" }, "kernelspec": { "name": "julia-1.10", "display_name": "Julia 1.10.2", "language": "julia" } }, "nbformat": 4 }