Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
601 views
unlisted
ubuntu2404
a

=bi��@sndZddlZddlmZddlmZddlmZddd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�ZdS)z6
Created on Fri Nov  7 19:15:57 2025

@author: davide
�N)�interpolate)�odeint)�	curve_fit�c
Csdt|||d�\}}}}	t||||||||	d�\}
}t|
dd�df|
dd�df|
dd�df|�S)zsreturns rotational dinamics from initial condition IC along time at Reynolds Rep for the spheroid with aspect ratio)�req�Rep)�IC�time�gammadot�r�b1�b2�b3�b4Nr��)�
load_betas�Einarsson_interface�split_orbits_and_get_C)rr�dirrr	r
rr
rrZnnnZttt�r�_/Users/davide/Downloads/Joint_paper_figures/jupyter_notebook_submission/figure_5/Einarsson15.py�deltaC_einarsson15srcCs�t�|d�}t�|d�}t�|d�}t�|d�}t�|dd�df|dd�df�}t�|dd�df|dd�df�}t�|dd�df|dd�df�}	t�|dd�df|dd�df�}
t�||�||�|	|�|
|�g�|}|S)zWLoads the graphically extrapolated coefficients from Einarsson et al., PoF 2015, Fig. 2zB1.txtzB2.txtzB3.txtzB4.txtNrr)�np�loadtxtrZinterp1d�array)�folderrrZB1dataZB2dataZB3dataZB4data�f1�f2�f3�f4�betasrrrrs$$$$&rc

Cs<t�gd�gd�gd�g�|}t�gd�gd�gd�g�|}	t�|t�|	|��}
t�|t�|t�|	|���}t�|t�|	t�|	|���}||}||}||}||}t�|||	|�||
|||
t�|	|�||
||
t�||�|t�|t�|	|��|||t�|	t�|	|��||S)zMCalculates the rotation rate according to Einarsson et al., PoF, 2015: eq. 39)r��?r)g�rr)rrr)r"rr)rr�dot)
�p�t�betar
rr
rr�Omega�EZpEpZpOEpZpEEprrr�rotation_Einarsson(s   r)c
Cs\|dd|dd}|}	t�|d|d|dg�}
tt|
|	||||||fd�}||	fS)zQManages the integration of the Einarsson rotation rate from a given initial_valuerrr)�args)rrrr))rr	r
rrr
rrr&ZsimtimeZpinitZptheoryrrrr2s
rcCs2||t�t�|�d|dt�|�d�S)Nr)r�sqrt�cos�sin)�phi�Crrrr�
jeffery_model<sr0cs��fdd�}zRt||t�|�dtjgdgd�\}}|jrLt�t�|��dntj}|d|fWSty|tjtjfYS0dS)Ncst||��S)N)r0)r.r/�rrr�model@szfit_C.<locals>.modelr��?)�bounds�p0)	rr�tan�inf�sizer+�diag�nan�	Exception)�thetar.rr2ZC_fit�covZC_stdrr1r�fit_C?s$ r>cCs�|dkrt�t�|��dk}nt�t�|��dk}tj|td�}t�|�|dd�<|��d}g}t|�D]N}t�|dd�|k�}	t�	||	||	�}
t�
||	�}|�t||
|��qjt�
|�jS)z&Method to split orbits in semi-periodsr3r)�dtyperN)r�diff�sign�
zeros_like�int�cumsum�max�range�where�arctan2�arccos�appendr>r�T)�n1�n2�n3r�sign_changeZorbit_labels�
num_orbitsr/�iZ
orbit_indsr.r<rrrrJsr)rNNN)�__doc__�numpyr�scipyrZscipy.integrater�scipy.optimizerrrr)rr0r>rrrrr�<module>s