# HG changeset patch # User paugier <pierre.augier@univ-grenoble-alpes.fr> # Date 1653296544 -7200 # Mon May 23 11:02:24 2022 +0200 # Node ID d171aa676d9a046ff4c0888354db8560921b011a # Parent 5cfc2a4b634dfbb8c967647729af91f2b303eeff Add first version fluiddyn_paper/2022strat_turb_toro diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -17,6 +17,7 @@ *.pyg *.bbl *.blg +*Notes.bib *.fls *.fdb_latexmk diff --git a/2022strat_turb_toro/Makefile b/2022strat_turb_toro/Makefile new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/Makefile @@ -0,0 +1,23 @@ +NAME = article + +$(NAME).pdf: figures + cd input && latexmk -shell-escape -pdf $(NAME).tex && rsync $(NAME).pdf ../$(NAME).pdf + +figures: + python py/make_figures.py SAVE + +clean: + rm -f tmp/table.tex + cd input && rm -f *.aux *.fdb_latexmk *.fls *.log *.bak* *.bbl *.blg *.out *Notes.bib + +cleantmp: + rm -rf tmp + +cleanall: clean cleantmp + rm -f *.pdf + +format: + cd input && formattex *.tex -i -v + +black: + black -l 82 py diff --git a/2022strat_turb_toro/README.md b/2022strat_turb_toro/README.md new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/README.md @@ -0,0 +1,5 @@ +# Source of a great article + +- The pdf file is produced with the command `make`. + +- The Latex code can be formatted with the command `make format`. diff --git a/2022strat_turb_toro/input/article.tex b/2022strat_turb_toro/input/article.tex new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/input/article.tex @@ -0,0 +1,327 @@ +\documentclass[% + aps, + superscriptaddress, + longbibliography, + 12pt, + onecolumn, + a4paper, + % preprint, + % reprint, + linenumbers, + showpacs, + showkeys, + % draft, + amsfonts, amssymb, amsmath]{revtex4-2} + +% The result seems nicer with revtex4-2, but +% Debian 9 (Stretch) does not have revtex4-2 + +\usepackage[utf8]{inputenc} +% \usepackage{epstopdf} % Converts .eps to +% \epstopdfsetup{update} +\usepackage[caption=false]{subfig} +\usepackage{hyperref} % Required for customising links and the PDF* + +\linespread{1.05} + +\hypersetup{pdfpagemode={UseOutlines}, +bookmarksopen=true, +bookmarksopenlevel=0, +hypertexnames=false, +colorlinks=true, % Set to false to disable coloring links +citecolor=blue, % The color of citations +linkcolor=red, % The color of references to document elements (sections, figures, etc) +urlcolor=black, % The color of hyperlinks (URLs) +pdfstartview={FitV}, +unicode, +breaklinks=true, +} +\usepackage{graphicx,amssymb,amsmath} +% \usepackage[english]{babel} +\usepackage{grffile} +\usepackage{color} +\usepackage{array} +\usepackage{hhline} + +\usepackage{ulem} +% \usepackage{float} + +\usepackage{siunitx} +\sisetup{ + inter-unit-product = \ensuremath{{}\!\cdot\!{}}, + detect-all, + separate-uncertainty = true, + exponent-product = \times, + space-before-unit = true, + output-decimal-marker = {,}, + multi-part-units = brackets, + range-phrase = --, + % allow-number-unit-breaks, + list-final-separator = { et }, + list-pair-separator = { et }, + abbreviations +} + +\setlength{\tabcolsep}{7pt} + +\usepackage{minted} + +\newcommand{\cor}[1]{\textcolor{red}{#1}} + +\newlength{\figwidth} +\setlength{\figwidth}{120mm} +% \setlength{\figwidth}{0.7\textwidth} % useful in single column + + +\newcommand{\R}{\mathcal{R}} + +\newcommand{\eps}{\varepsilon} +\newcommand{\epsK}{{\varepsilon_{\!\scriptscriptstyle K}}} +\newcommand{\epsKK}{{\varepsilon_{\!\scriptscriptstyle K 2}}} +\newcommand{\epsKKKK}{{\varepsilon_{\!\scriptscriptstyle K 4}}} +\newcommand{\epsA}{{\varepsilon_{\!\scriptscriptstyle A}}} + + +\newcommand{\xx}{\boldsymbol{x}} +\newcommand{\kk}{\boldsymbol{k}} +\newcommand{\eek}{\boldsymbol{e}_\boldsymbol{k}} +\newcommand{\eeh}{\boldsymbol{e}_h} +\newcommand{\eetheta}{\boldsymbol{e}_\theta} +\newcommand{\eez}{\boldsymbol{e}_z} +\newcommand{\cc}{\boldsymbol{c}} +\newcommand{\uu}{\boldsymbol{u}} +\newcommand{\vv}{\boldsymbol{v}} +\newcommand{\ff}{\boldsymbol{f}} +\newcommand{\bomega}{\boldsymbol{\omega}} +\newcommand{\bnabla}{\boldsymbol{\nabla}} +\newcommand{\Dt}{\mbox{D}_t} +\newcommand{\p}{\partial} +\newcommand{\mean}[1]{\langle #1 \rangle} +\newcommand{\epsP}{\varepsilon_{\!\scriptscriptstyle P}} +\newcommand{\epsm}{\varepsilon_{\!\scriptscriptstyle m}} +\newcommand{\CKA}{C_{K\rightarrow A}} +\newcommand{\D}{\mbox{D}} +\newcommand{\diff}{\text{d}} +\newcommand{\bv}{Brunt-V\"ais\"al\"a} +\newcommand{\kmax}{k_{\max}} + +\newcommand{\todo}[1]{\textcolor{red}{TODO: #1}} + +% fix an incompatibility between lineno and align +% see https://tex.stackexchange.com/a/55297/142591 +\newcommand*\patchAmsMathEnvironmentForLineno[1]{% + \expandafter\let\csname old#1\expandafter\endcsname\csname #1\endcsname + \expandafter\let\csname oldend#1\expandafter\endcsname\csname end#1\endcsname + \renewenvironment{#1}% + {\linenomath\csname old#1\endcsname}% + {\csname oldend#1\endcsname\endlinenomath}}% +\newcommand*\patchBothAmsMathEnvironmentsForLineno[1]{% + \patchAmsMathEnvironmentForLineno{#1}% + \patchAmsMathEnvironmentForLineno{#1*}}% +\AtBeginDocument{% +\patchBothAmsMathEnvironmentsForLineno{equation}% +\patchBothAmsMathEnvironmentsForLineno{align}% +\patchBothAmsMathEnvironmentsForLineno{flalign}% +\patchBothAmsMathEnvironmentsForLineno{alignat}% +\patchBothAmsMathEnvironmentsForLineno{gather}% +\patchBothAmsMathEnvironmentsForLineno{multline}% +} + +\begin{document} + +\title{A great title} + +\author{Pierre Augier} +\author{Vincent Reneuve} +\author{Jason Reneuve} + +\email[]{pierre.augier@univ-grenoble-alpes.fr} +\affiliation{Laboratoire des Ecoulements G\'eophysiques et Industriels, Universit\'e +Grenoble Alpes, CNRS, Grenoble-INP, F-38000 Grenoble, France} + +\begin{abstract} + +Blabla + +\end{abstract} + +%---------------------------------------------------------------------------------------- + +% Print the title +\maketitle + +%---------------------------------------------------------------------------------------- +% ARTICLE CONTENTS +%---------------------------------------------------------------------------------------- + +\section{Introduction} + +\input{intro.tex} +%\input{old_intro.tex} + +%------------------------------------------------ +\section{Numerical setup} +\label{sec:num} +%------------------------------------- + +The numerical simulations presented in this article are performed using the +pseudospectral solver \mintinline{python}{ns3d.strat} from the FluidSim Python package +\cite{fluiddyn,fluidfft,fluidsim}. Using this solver, we integrate the +three-dimensional Navier-Stokes equations under the Boussinesq approximation: +\begin{align} +\p_t\vv + (\vv \cdot \bnabla)\vv = b\boldsymbol{e}_z - \frac{1}{\rho_0}\bnabla p + +\nu_2\nabla^2\vv + \nu_4\nabla^4\vv + \ff,\label{ns} \\ +\p_t{b} + (\vv \cdot \bnabla)b = -N^2v_z + \kappa_2\nabla^2{b} + +\kappa_4\nabla^4{b},\label{buoy} +\end{align} +where $\vv$ is the velocity, $p$ the pressure, $b=-g\delta\rho/\rho_0$, with $\rho_0$ +the mean density and $\delta\rho$ the departure from the stable linear density +stratification. For all simulations, the second-order viscosity is set to the value for +water in usual temperature and pressure conditions, $\nu_2=10^{-6}$\,m$^2$/s. + +For some simulations, a fourth-order hyperviscosity term is added. The fourth-order +viscosity $\nu_4$ is left as a free parameter and adapted to the resolution of +simulations in order to ensure that dissipative scales are well resolved. Similarly, +the equation of motion \eqref{buoy} for the buoyancy field $b$ presents both second and +fourth order diffusive terms, with corresponding diffusion coefficients $\kappa_2$ and +$\kappa_4$. We can then build two different Prandtl numbers +$\text{Pr}_i=\nu_i/\kappa_i$ for $i=2,4$. In all simulations, both those Prandtl +numbers are set to unity, such that $\kappa_2=\nu_2$ and $\kappa_4=\nu_4$. The use of +both normal and hyperviscosity is an important tool for the comparison with +experiments. More specifically, we use the measure of the turbulent kinetic +dissipations $\epsKK$ and $\epsKKKK$ based on both viscosities, and the ratio +$\epsKK/\epsK$ where $\epsK=\epsKK+\epsKKKK$, as an indicator of how close the +simulations we perform are to proper DNS of the Boussinesq equations with only water +viscosity. For a set of physical parameters, the needed hyperviscosity decreases when +the resolution is increased and the ratio $\epsKK/\epsK$ grows towards unity. + +For all simulations we take $N=0.6$\,rad/s and $\nu_2=10^{-6}$\,m$^2$/s. The remaining +free parameters are the resolution $n_x\times n_y\times n_z$, the reduced forcing +frequency $F=\omega_f/N$ and amplitude $a$, and the hyperviscosity $\nu_4$ which is +adapted to the other parameters so that the dissipative scales are well-resolved. The +simulations were performed on a local cluster at LEGI for resolutions up to +$480\times480\times80$, and on the national CINES cluster Occigen for resolutions up to +$2304\times2304\times384$. Parameters and dimensionless numbers for each simulations +are summarized in table~\ref{table_simul}. The turbulent nondimensional numbers are +computed from the statistically stationary flows as $F_h = \epsK / ({U_h}^2 N)$, $\R_2 += \epsK / (\nu_2 N^2)$ and $\R_4 = \epsK{U_h}^2 / (\nu_4 N ^ 4)$, where $\epsK$ is the +mean kinetic energy dissipation and $U_h$ the rms horizontal velocity. The results +presented in this article are obtained from periods of the simulation when a steady +state has been approximately reached. Because the time scales of the flows studied here +are very long, finding such steady-state period can be very difficult and +computationally costly. In order to reach an approximately steady state in a reasonable +time, we start all the simulations at a reduced resolution $240\times240\times40$, and +increase the resolution step by step only when a sufficiently stationary state has been +reached. When such a state is observed, specific outputs are turned on and the +simulation is ran further for 10 to 20 minutes of equation time in order to produce +substantial data to analyze, before increasing the resolution again if needed. + + +%% Method: simulations 1 couple (N, R_i) + +% \input{../tmp/table_N?_Ri?.tex} + +\todo{Include product kmax * Taylor microscale} + +\begin{figure} +% \centerline{ +% \includegraphics[width=0.48\textwidth]{% +% ../tmp/fig_E_vs_time_N?_Ri?} +% \includegraphics[width=0.48\textwidth]{% +% ../tmp/fig_means_versus_kmaxeta_N?_Ri?} +% } +\caption{(a) Energy versus time for simulations at different resolutions for $N=$ and +$Ri=$. (b) Averaged quantities versus $\kmax\eta$ for the same simulations. +\label{fig:method-N?-Ri?}} +\end{figure} + +\begin{figure}% [H] +% \centerline{ +% \includegraphics[width=0.48\textwidth]{% +% ../tmp/fig_E_vs_kh_N?_Ri?} +% \includegraphics[width=0.48\textwidth]{% +% ../tmp/fig_E_vs_kz_N?_Ri?} +% } +\caption{Horizontal (a) and vertical (b) spectra for simulations at different +resolutions for $N=$ and $Ri=$. \label{fig:method-N?-Ri?-spectra}} +\end{figure} + +%% Method: resolution and hyperdiffusivity for the better simulations for each couple (N, R_i) + +\begin{figure} +\centerline{ +\includegraphics[width=0.48\textwidth]{% +../tmp/fig_kmaxeta_vs_FhR} +\includegraphics[width=0.48\textwidth]{% +../tmp/fig_epsK2overepsK_vs_FhR} +} +\caption{. \label{fig:method-resolution-hyperdiffusivity}} +\end{figure} + +% \input{../tmp/table_better_simuls.tex} + +\section{Results} + +\subsection{Large and small scale isotropy coefficients} + +%% Large scale isotropy + +\begin{figure} +\centerline{ +\includegraphics[width=0.48\textwidth]{% +../tmp/fig_isotropy_velo_vs_Fh} +\includegraphics[width=0.48\textwidth]{% +../tmp/fig_isotropy_velo_vs_R} +} +\caption{Large scale isotropy coefficients. \label{fig:large-scale-isotropy}} +\end{figure} + +%% Small scale isotropy + +\begin{figure} +\centerline{ +\includegraphics[width=0.48\textwidth]{% +../tmp/fig_isotropy_diss_vs_Fh} +\includegraphics[width=0.48\textwidth]{% +../tmp/fig_isotropy_diss_vs_R} +} +\caption{Small scale isotropy coefficients. \label{fig:small-scale-isotropy}} +\end{figure} + +%% Isotropy coefficient: summary + +\begin{figure} +\centerline{ +\includegraphics[width=0.7\textwidth]{% +../tmp/fig_isotropy_coef_vs_FhR} +} +\caption{Large and small scale isotropy coefficients. +\label{fig:isotropy-coefficients}} +\end{figure} + + +\subsection{Aspect ratio of integral scales} + +\subsection{Mixing coefficient} + +\subsection{Spatial spectra and spectral energy budget} + +\section{Conclusions and perspectives} + +We performed numerical simulations of a stratified turbulent flow, using a forcing +mechanism... + +\begin{acknowledgments} +This project has received funding from the European Research Council (ERC) +under the European Union's Horizon 2020 research and innovation program (Grant +No. 647018-WATU). It was also partially supported by the Simons Foundation +through the Simons collaboration on wave turbulence. Part of this work was +performed using resources provided by \href{https://www.cines.fr/}{CINES} under +GENCI allocation number A0080107567. +\end{acknowledgments} + +%\appendix\section{A great appendix} +%\label{appendix} + +\bibliography{biblio} +\end{document} diff --git a/2022strat_turb_toro/input/biblio.bib b/2022strat_turb_toro/input/biblio.bib new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/input/biblio.bib @@ -0,0 +1,257 @@ +%% Theses +@phdthesis{Linares2020, + title={Numerical study of 2D stratified turbulence forced by internal gravity waves}, + author={Linares, Miguel Calpe}, + year={2020}, + school={Universit{\'e} Grenoble Alpes [2020-....]} +} + +%% Articles +@article{fluiddyn, +doi = {10.5334/jors.237}, +year = {2019}, +publisher = {Ubiquity Press, Ltd.}, +volume = {7}, +author = {Pierre Augier and Ashwin Vishnu Mohanan and Cyrille Bonamy}, +title = {{FluidDyn}: A Python Open-Source Framework for Research and Teaching in Fluid Dynamics + by Simulations, Experiments and Data Processing}, +journal = {Journal of Open Research Software} +} + +@article{fluidfft, +doi = {10.5334/jors.238}, +year = {2019}, +publisher = {Ubiquity Press, Ltd.}, +volume = {7}, +author = {Ashwin Vishnu Mohanan and Cyrille Bonamy and Pierre Augier}, +title = {{FluidFFT}: Common {API} (C$++$ and Python) + for Fast Fourier Transform {HPC} Libraries}, +journal = {Journal of Open Research Software} +} + +@article{fluidsim, +doi = {10.5334/jors.239}, +year = {2019}, +publisher = {Ubiquity Press, Ltd.}, +volume = {7}, +author = {Mohanan, Ashwin Vishnu and Bonamy, Cyrille and Linares, Miguel + Calpe and Augier, Pierre}, +title = {{FluidSim}: {Modular}, {Object}-{Oriented} {Python} {Package} for + {High}-{Performance} {CFD} {Simulations}}, +journal = {Journal of Open Research Software} +} + +@article{Savaro2020, + title = {Generation of weakly nonlinear turbulence of internal gravity waves in the Coriolis facility}, + author = {Savaro, Cl\'ement and Campagne, Antoine and Linares, Miguel Calpe and Augier, Pierre and Sommeria, Jo\"el and Valran, Thomas and Viboud, Samuel and Mordant, Nicolas}, + journal = {Phys. Rev. Fluids}, + volume = {5}, + issue = {7}, + pages = {073801}, + numpages = {22}, + year = {2020}, + month = {Jul}, + publisher = {American Physical Society}, + doi = {10.1103/PhysRevFluids.5.073801}, + url = {https://link.aps.org/doi/10.1103/PhysRevFluids.5.073801} +} +@article{Angot1999, + doi = {10.1007/s002110050401}, + url = {https://doi.org/10.1007/s002110050401}, + year = {1999}, + month = feb, + publisher = {Springer Science and Business Media {LLC}}, + volume = {81}, + number = {4}, + pages = {497--520}, + author = {Philippe Angot and Charles-Henri Bruneau and Pierre Fabrie}, + title = {A penalization method to take into account obstacles in incompressible viscous flows}, + journal = {Numerische Mathematik} +} + +@article{Garrett1979, + title={Internal waves in the ocean}, + author={Garrett, Christopher and Munk, Walter}, + journal={Annual review of fluid mechanics}, + volume={11}, + number={1}, + pages={339--369}, + year={1979}, + publisher={Annual Reviews 4139 El Camino Way, PO Box 10139, Palo Alto, CA 94303-0139, USA} +} + +@article{polzin2011toward, + title={Toward regional characterizations of the oceanic internal wavefield}, + author={Polzin, Kurt L and Lvov, Yuri V}, + journal={Reviews of geophysics}, + volume={49}, + number={4}, + year={2011}, + publisher={Wiley Online Library} +} + +@article{lindborg2007stratified, + title={Stratified turbulence forced in rotational and divergent modes}, + author={Lindborg, Erik and Brethouwer, Geert}, + journal={J. Fluid Mech.}, + volume={586}, + pages={83--108}, + year={2007}, + publisher={Cambridge University Press} +} + +@article{riley2008stratified, + title={Stratified turbulence: A possible interpretation of some geophysical turbulence measurements}, + author={Riley, James J and Lindborg, Erik}, + journal={Journal of the Atmospheric Sciences}, + volume={65}, + number={7}, + pages={2416--2424}, + year={2008} +} + +@article{lindborg2006energy, + title={The energy cascade in a strongly stratified fluid}, + author={Lindborg, Erik}, + journal={J. Fluid Mech.}, + volume={550}, + pages={207--242}, + year={2006}, + publisher={Cambridge University Press} +} + +@article{deBruynKops2019effects, + title={The effects of stable stratification on the decay of initially isotropic homogeneous turbulence}, + author={de Bruyn Kops, Stephen M and Riley, James J}, + journal={J. Fluid Mech.}, + volume={860}, + pages={787--821}, + year={2019}, + publisher={Cambridge University Press} +} + +@article{brethouwer_billant_lindborg_chomaz_2007, +title={Scaling analysis and simulation of strongly stratified turbulent flows}, +volume={585}, +DOI={10.1017/S0022112007006854}, +journal={J. Fluid Mech.}, +publisher={Cambridge University Press}, +author={BRETHOUWER, G. and BILLANT, P. +and LINDBORG, E. and CHOMAZ, J.-M.}, +year={2007}, +pages={343–368} +} + +@article{waite2006stratified, + title={Stratified turbulence generated by internal gravity waves}, + author={Waite, Michael L and Bartello, Peter}, + journal={J. Fluid Mech.}, + volume={546}, + pages={313--339}, + year={2006}, + publisher={Cambridge University Press} +} + +@phdthesis{linares2020numerical, + title={Numerical study of 2D stratified turbulence forced by internal gravity waves}, + author={Linares, Miguel Calpe}, + year={2020}, + school={Universit{\'e} Grenoble Alpes [2020-....]} +} + +@article{LeReun2018parametric, + title={Parametric instability and wave turbulence driven by tidal excitation of internal waves}, + author={Le Reun, Thomas and Favier, Benjamin and Le Bars, Michael}, + journal={J. Fluid Mech.}, + volume={840}, + pages={498--529}, + year={2018}, + publisher={Cambridge University Press} +} + +@article{Portwood2016robust, + title={Robust identification of dynamically distinct regions in stratified turbulence}, + author={Portwood, Gavin D and de Bruyn Kops, Stephen M and Taylor, John Ryan and Salehipour, H and Caulfield, CP}, + journal={J. Fluid Mech.}, + volume={807}, + year={2016}, + publisher={Cambridge University Press} +} + +@article{Maffioli2020, + doi = {10.1103/physrevfluids.5.114802}, + url = {https://doi.org/10.1103/physrevfluids.5.114802}, + year = {2020}, + month = nov, + publisher = {American Physical Society ({APS})}, + volume = {5}, + number = {11}, + author = {Andrea Maffioli and Alexandre Delache and Fabien S. Godeferd}, + title = {Signature and energetics of internal gravity waves in stratified turbulence}, + journal = {Physical Review Fluids} +} + +@article{Craya1958, + title={Contribution à l'analyse de la turbulence associée à des vitesses moyennes}, + author={Craya, Antoine}, + journal={Pub. Sci. Tech. du Ministère de l'Air (France) (345)}, + year={1958} +} + +@article{Herring1974, + title={Approach of axisymmetric turbulence to isotropy}, + author={Herring, JR}, + journal={Phys. Fluids}, + volume={17}, + number={5}, + pages={859--872}, + year={1974} +} + +@article{RileyLelong2000, + title={Fluid motions in the presence of strong stable stratification}, + author={Riley, James J and Lelong, Marie-Pascale}, + journal={Annual review of fluid mechanics}, + volume={32}, + number={1}, + pages={613--657}, + year={2000} +} + +@article{Cambon2001, + title={Turbulence and vortex structures in rotating and stratified flows}, + author={Cambon, Claude}, + journal={European Journal of Mechanics-B/Fluids}, + volume={20}, + number={4}, + pages={489--510}, + year={2001} +} + +@article{CaillolZeitlin2000, + title={Kinetic equations and stationary energy spectra of weakly nonlinear internal gravity waves}, + author={Caillol, Ph and Zeitlin, V}, + journal={Dynamics of atmospheres and oceans}, + volume={32}, + number={2}, + pages={81--112}, + year={2000} +} + +@article{smith2002generation, + title={Generation of slow large scales in forced rotating stratified turbulence}, + author={Smith, Leslie M and Waleffe, Fabian}, + journal={J. Fluid Mech.}, + volume={451}, + pages={145--168}, + year={2002} +} + +@article{augier2015stratified, + title={Stratified turbulence forced with columnar dipoles: numerical study}, + author={Augier, Pierre and Billant, Paul and Chomaz, Jean-Marc}, + journal={J. Fluid Mech.}, + volume={769}, + pages={403--443}, + year={2015} + } diff --git a/2022strat_turb_toro/input/intro.tex b/2022strat_turb_toro/input/intro.tex new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/input/intro.tex @@ -0,0 +1,2 @@ + +Blabla... \ No newline at end of file diff --git a/2022strat_turb_toro/py/make_figures.py b/2022strat_turb_toro/py/make_figures.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/make_figures.py @@ -0,0 +1,32 @@ +from runpy import run_path + +import matplotlib.pyplot as plt + +from util import has_to_be_made, has_to_save, here + + +def make_fig(name, source=None): + if source is None: + source = f"save_{name}.py" + if has_to_be_made(f"fig_{name}", source): + # interesting: transonic/inspect bug without str(...)! + # https://foss.heptapod.net/fluiddyn/transonic/-/merge_requests/104 + run_path(str(here / source)) + + +make_fig("methods_N40_Ri20", "save_fig_methods.py") + +make_fig("kmaxeta_vs_FhR") +make_fig("epsK2overepsK_vs_FhR") + +make_fig("isotropy_coef_vs_FhR") +make_fig("isotropy_diss_vs_R") +make_fig("isotropy_diss_vs_Fh") +make_fig("isotropy_velo_vs_R") +make_fig("isotropy_velo_vs_Fh") + +make_fig("mixing_coef_vs_FhR") +make_fig("mixing_coef_vs_Fh") + +if not has_to_save: + plt.show() diff --git a/2022strat_turb_toro/py/save_epsK2overepsK_vs_FhR.py b/2022strat_turb_toro/py/save_epsK2overepsK_vs_FhR.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_epsK2overepsK_vs_FhR.py @@ -0,0 +1,29 @@ +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, + "Fh", + "R2", + c=df["epsK2/epsK"], + logy=True, + vmin=0, + vmax=1, + s=35, +) +ax.set_xlim(right=1) +ax.set_ylim(top=1e3) +ax.set_xlabel("$F_h$") +ax.set_ylabel(r"$\mathcal{R} = Re {F_h}^2$") + +fig = ax.figure +fig.tight_layout() +fig.text(0.85, 0.07, r"$\varepsilon_{K2} / \varepsilon_K$", fontsize=12) + +save_fig(fig, "fig_epsK2overepsK_vs_FhR.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_fig_methods.py b/2022strat_turb_toro/py/save_fig_methods.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_fig_methods.py @@ -0,0 +1,55 @@ +import matplotlib.pyplot as plt + +from util import save_fig, get_paths_couple, get_customized_dataframe + +N = 40 +Rb = 20 + +paths = get_paths_couple(N, Rb) + +print([p.name for p in paths]) + +df = get_customized_dataframe(paths) + +print(df) + +fig, axes = plt.subplots(nrows=2, sharex=True) + +ax0, ax1 = axes + +k_max_eta = df["k_max*eta"] + +ax0.plot( + k_max_eta, + df["epsK2/epsK"], + "s:", + label=r"$\varepsilon_{K2} / (\varepsilon_{K2} + \varepsilon_{K4})$", +) + +ax0.set_title( + rf"$N = {N}$, " + + r"$\mathcal{R}_i" + + rf" = {Rb}$, $Re = {int(df.Re.max())}$ ($F_h = {df.Fh.mean():.2f}$, " + r"$\mathcal{R}_2 = " + rf"{df.R2.mean():.1f}$)" +) + +ax0.set_ylim([0, 1]) +ax0.set_ylabel(r"$\varepsilon_{K2} / (\varepsilon_{K2} + \varepsilon_{K4})$") + +ax1.set_xlabel("$k_{max} \eta$") + +ax1.plot( + k_max_eta, + df["Gamma"], + "o:", + label=r"$\Gamma = \varepsilon_A / \varepsilon_K$", +) +ax1.plot(k_max_eta, df["I_velocity"], "s:", label=r"$I_{velo}$") +ax1.plot(k_max_eta, df["I_dissipation"], "^:", label=r"$I_{diss}$") +ax1.legend() + +fig.tight_layout() +save_fig(fig, f"fig_methods_N{N}_Ri{Rb}.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_isotropy_coef_vs_FhR.py b/2022strat_turb_toro/py/save_isotropy_coef_vs_FhR.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_isotropy_coef_vs_FhR.py @@ -0,0 +1,45 @@ +import numpy as np +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, + "Fh", + "R2", + c=df["I_velocity"], + logy=True, + vmin=0.2, + vmax=0.8, + s=50 * df["I_dissipation"], +) +ax.set_xlim(right=1) +ax.set_ylim(top=1e3) +ax.set_xlabel("$F_h$") +ax.set_ylabel("$\mathcal{R} = Re {F_h}^2$") +fig = ax.figure +fig.tight_layout() + +fig.text(0.84, 0.07, r"$I_\mathit{velocity}$", fontsize=12) + +ax_legend = fig.add_axes([0.17, 0.76, 0.2, 0.16]) +ax_legend.set_xticklabels([]) +ax_legend.set_xticks([]) +ax_legend.set_yticklabels([]) +ax_legend.set_yticks([]) +isotropy_diss = np.array([0.1, 0.5, 0.9]) +heights = np.array([0.2, 0.5, 0.8]) +ax_legend.scatter([0.15, 0.15, 0.15], heights, s=50 * isotropy_diss) +ax_legend.set_xlim([0, 1]) +ax_legend.set_ylim([0, 1]) + +for h, i in zip(heights, isotropy_diss): + ax_legend.text(0.28, h - 0.06, r"$I_\mathit{diss} = " + f"{i}$") + + +save_fig(fig, "fig_isotropy_coef_vs_FhR.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_isotropy_diss_vs_Fh.py b/2022strat_turb_toro/py/save_isotropy_diss_vs_Fh.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_isotropy_diss_vs_Fh.py @@ -0,0 +1,30 @@ +import numpy as np +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, "Fh", "I_dissipation", c=np.log10(df["R2"]), vmin=0.5, vmax=2, logy=True +) + +ax.set_xlabel("$F_h$") +ax.set_ylabel(r"$I_{diss}$") + +# xs = np.linspace(1e-2, 1e-1, 4) +# ax.plot(xs, 8e0 * xs**1) +# ax.text(0.03, 0.4, "${F_h}^1$") + +# ax.plot(xs, 8e1 * xs**2) +# ax.text(0.07, 0.2, "$F_h^{2}$") + +fig = ax.figure + +fig.text(0.84, 0.07, r"$\log_{10}(\mathcal{R})$", fontsize=12) + +fig.tight_layout() +save_fig(fig, "fig_isotropy_diss_vs_Fh.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_isotropy_diss_vs_R.py b/2022strat_turb_toro/py/save_isotropy_diss_vs_R.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_isotropy_diss_vs_R.py @@ -0,0 +1,21 @@ +import numpy as np +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot(df, "R2", "I_dissipation", c=np.log10(df["Fh"]), vmin=-2, vmax=-1, logy=True) + +ax.set_xlabel(r"$\mathcal{R}$") +ax.set_ylabel("$I_{diss}$") + +fig = ax.figure + +fig.text(0.84, 0.07, r"$\log_{10}(F_h)$", fontsize=12) + +fig.tight_layout() +save_fig(fig, "fig_isotropy_diss_vs_R.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_isotropy_velo_vs_Fh.py b/2022strat_turb_toro/py/save_isotropy_velo_vs_Fh.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_isotropy_velo_vs_Fh.py @@ -0,0 +1,30 @@ +import numpy as np +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, "Fh", "I_velocity", c=np.log10(df["R2"]), vmin=0.5, vmax=2, logy=True +) + +ax.set_xlabel("$F_h$") +ax.set_ylabel(r"$I_{velocity}$") + +xs = np.linspace(1e-2, 1e-1, 4) +ax.plot(xs, 8e0 * xs**1) +ax.text(0.03, 0.4, "${F_h}^1$") + +# ax.plot(xs, 8e1 * xs**2) +# ax.text(0.07, 0.2, "$F_h^{2}$") + +fig = ax.figure + +fig.text(0.84, 0.07, r"$\log_{10}(\mathcal{R})$", fontsize=12) + +fig.tight_layout() +save_fig(fig, "fig_isotropy_velo_vs_Fh.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_isotropy_velo_vs_R.py b/2022strat_turb_toro/py/save_isotropy_velo_vs_R.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_isotropy_velo_vs_R.py @@ -0,0 +1,23 @@ +import numpy as np +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, "R2", "I_velocity", c=np.log10(df["Fh"]), vmin=-2, vmax=-1, logy=True +) + +ax.set_xlabel(r"$\mathcal{R}$") +ax.set_ylabel("$I_{velo}$") + +fig = ax.figure + +fig.text(0.84, 0.07, r"$\log_{10}(F_h)$", fontsize=12) + +fig.tight_layout() +save_fig(fig, "fig_isotropy_velo_vs_R.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_kmaxeta_vs_FhR.py b/2022strat_turb_toro/py/save_kmaxeta_vs_FhR.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_kmaxeta_vs_FhR.py @@ -0,0 +1,29 @@ +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, + "Fh", + "R2", + c=df["k_max*eta"], + logy=True, + vmin=0.2, + vmax=1.2, + s=35, +) +ax.set_xlim(right=1) +ax.set_ylim(top=1e3) +ax.set_xlabel("$F_h$") +ax.set_ylabel(r"$\mathcal{R} = Re {F_h}^2$") + +fig = ax.figure +fig.tight_layout() +fig.text(0.85, 0.07, r"$k_{max} \eta$", fontsize=12) + +save_fig(fig, "fig_kmaxeta_vs_FhR.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_mixing_coef_vs_Fh.py b/2022strat_turb_toro/py/save_mixing_coef_vs_Fh.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_mixing_coef_vs_Fh.py @@ -0,0 +1,38 @@ +import numpy as np +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, + "Fh", + "Gamma", + c=np.log10(df["R2"]), + logy=True, + vmin=0.3, + vmax=2, + s=35, +) +# ax.set_xlim(right=1) +# ax.set_ylim(top=1e3) +ax.set_xlabel("$F_h$") +ax.set_ylabel(r"$\Gamma=\epsilon_A / \epsilon_K$") + +xs = np.linspace(1.5e-1, 5e-1, 4) +ax.plot(xs, 5e-2 * xs**-1) +ax.text(0.16, 0.12, "${F_h}^{-1}$") + +xs = np.linspace(6e-1, 4, 4) +ax.plot(xs, 5e-2 * xs**-2) +ax.text(1.2, 0.05, "${F_h}^{-2}$") + +fig = ax.figure +fig.tight_layout() +fig.text(0.85, 0.07, r"$\mathcal{R}$", fontsize=12) + +save_fig(fig, "fig_mixing_coef_vs_Fh.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/save_mixing_coef_vs_FhR.py b/2022strat_turb_toro/py/save_mixing_coef_vs_FhR.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/save_mixing_coef_vs_FhR.py @@ -0,0 +1,29 @@ +import matplotlib.pyplot as plt + +from util import save_fig, plot + +from util_dataframe import df + +ax = plot( + df, + "Fh", + "R2", + c=df["Gamma"], + logy=True, + vmin=0.2, + vmax=0.6, + s=35, +) +ax.set_xlim(right=1) +ax.set_ylim(top=1e3) +ax.set_xlabel("$F_h$") +ax.set_ylabel(r"$\mathcal{R} = Re {F_h}^2$") + +fig = ax.figure +fig.tight_layout() +fig.text(0.85, 0.07, r"$\Gamma=\frac{\epsilon_A}{\epsilon_K}$", fontsize=12) + +save_fig(fig, "fig_mixing_coef_vs_FhR.png") + +if __name__ == "__main__": + plt.show() diff --git a/2022strat_turb_toro/py/util.py b/2022strat_turb_toro/py/util.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/util.py @@ -0,0 +1,151 @@ +from pathlib import Path +import os +from itertools import product +import sys + +import matplotlib.pyplot as plt + +from fluiddyn.util import has_to_be_made as _has_to_be_made +from fluidsim.util import times_start_last_from_path, get_dataframe_from_paths + +path_base = os.environ["STRAT_TURB_TORO2022"] + +paths_all = sorted(Path(path_base).glob("simul_folders/ns3d*")) + +here = Path(__file__).absolute().parent +tmp_dir = here.parent / "tmp" +tmp_dir.mkdir(exist_ok=True) + + +def has_to_be_made(name, sources: list): + + if not isinstance(name, str): + names = name + return any(has_to_be_made(name, sources) for name in names) + + if isinstance(sources, str): + sources = [sources] + + sources.append("util.py") + + if not name.endswith(".png"): + name += ".png" + + return _has_to_be_made(tmp_dir / name, sources, source_dir=here) + + +height = 3.7 +plt.rc("figure", figsize=(1.33 * height, height)) + + +def get_paths_couple(N, Rb, reverse=False): + str_N = f"_N{N}_" + str_Rb = f"_Rb{Rb:.3g}_" + str_Rb2 = f"_Rb{Rb}_" + paths_couple = [ + p + for p in paths_all + if str_N in p.name and (str_Rb in p.name or str_Rb2 in p.name) + ] + paths_couple.sort(key=lambda p: int(p.name.split("x")[1]), reverse=reverse) + return paths_couple + + +def get_path_finer_resol(N, Rb): + paths_couple = get_paths_couple(N, Rb, reverse=True) + for path in paths_couple: + t_start, t_last = times_start_last_from_path(path) + if t_last > t_start + 1: + return path + + +def lprod(a, b): + return list(product(a, b)) + + +couples320 = set( + lprod([10, 20, 40], [5, 10, 20, 40, 80, 160]) + + lprod([30], [10, 20, 40]) + + lprod([6.5], [100, 200]) + + lprod([4], [250, 500]) + + lprod([3], [450, 900]) + + lprod([2], [1000, 2000]) + + lprod([0.66], [9000, 18000]) + + [(14.5, 20), (5.2, 150), (2.9, 475), (1.12, 3200), (0.25, 64000)] +) + +couples320.add((80, 10)) +couples320.add((120, 10)) +couples320.remove((40, 160)) + +# Small Rb +couples320.update(lprod([20], [1, 2])) +couples320.update(lprod([40], [1, 2])) +couples320.update(lprod([80], [0.5, 1])) + +has_to_save = "SAVE" in sys.argv + + +def save_fig(fig, name): + if has_to_save: + fig.savefig(tmp_dir / name) + + +def customize(result, sim): + result["Rb"] = float(sim.params.short_name_type_run.split("_Rb")[-1]) + result["nx"] = sim.params.oper.nx + result["nz"] = sim.params.oper.nz + + +def get_customized_dataframe(paths): + + df = get_dataframe_from_paths( + paths, tmin="t_start+2", use_cache=1, customize=customize + ) + df["Re"] = df.Rb * df.N**2 + + columns_old = df.columns.tolist() + + # fmt: off + first_columns = [ + "N", "Rb", "Re", "nx", "nz", "Fh", "R2", "k_max*eta", "epsK2/epsK", "Gamma", + "lx1", "lx2", "lz1", "lz2", "I_velocity", "I_dissipation"] + # fmt: on + + columns = first_columns.copy() + for key in columns_old: + if key not in columns: + columns.append(key) + + df = df[columns] + return df + + +def plot( + df, + x, + y, + logx=True, + logy=False, + c=None, + vmin=None, + vmax=None, + s=None, +): + ax = df.plot.scatter( + x=x, + y=y, + logx=logx, + logy=logy, + c=c, + edgecolors="k", + vmin=vmin, + vmax=vmax, + s=s, + ) + pc = ax.collections[0] + pc.set_cmap("inferno") + + if c is not None: + plt.colorbar(pc, ax=ax) + return ax diff --git a/2022strat_turb_toro/py/util_dataframe.py b/2022strat_turb_toro/py/util_dataframe.py new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/py/util_dataframe.py @@ -0,0 +1,9 @@ +from util import couples320, get_path_finer_resol, get_customized_dataframe + +paths = [] +for N, Rb in sorted(couples320): + paths.append(get_path_finer_resol(N, Rb)) + +print(f"Using {len(paths)} simulations") + +df = get_customized_dataframe(paths) diff --git a/2022strat_turb_toro/requirements.txt b/2022strat_turb_toro/requirements.txt new file mode 100644 --- /dev/null +++ b/2022strat_turb_toro/requirements.txt @@ -0,0 +1,1 @@ +formattex diff --git a/reply_Zwart2020/requirements.txt b/reply_Zwart2020/requirements.txt --- a/reply_Zwart2020/requirements.txt +++ b/reply_Zwart2020/requirements.txt @@ -1,2 +1,2 @@ -pandoc-include==0.8.4 +pandoc-include panflute==1.12