U
    _                     @   s   d dl mZ d dlmZ d dlZd dlmZ d dl	m
Z d dlZd dlmZ d dlmZ dZed Zed Zdd Zd	d
 Zdd Zdd ZdddZdS )    )
KineticGas)cubicNz6/home/ubuntu/Home/Documents/7_semester/irrev_prosjekt/zdata/zplots/alpha_T0/c                 C   s   t || |  t | S N)npexp)nab r
   X/home/ubuntu/Home/Documents/7_semester/irrev_prosjekt_renskriv/plotting/plot_alpha_t0.pyfit_func   s    r   c                 C   s  t dd tddD }t t|df}t t|}tjdd}tjdd|d	d
}dd tdD }|	|d |d< tddD ]}|j	|| |d d||< qtdD ]}tj
||  dd qt }|| d t|D ]T\}}	td|	d t }
t| |ddg|	d}t |
 ||< |j|j|jg||< q| }dddg}tdD ]:}t||  tj||| dd tj|| dd qVt|d  tj||dd tjddd tjddd tjd d!d" d S )#Nc                 S   s   g | ]}|qS r
   r
   .0ir
   r
   r   
<listcomp>   s     z$plot_convergence.<locals>.<listcomp>         )   	   )figsize   皙?)ncolsnrowsfigurehspacec                 S   s   g | ]}d qS r   r
   r   r
   r
   r   r      s     r   )sharexF)visibleSRK	Computingorder approximation皙?皙?
mole_fracsNz$d_{-1}$z$d_0$z$d_1$blackcolor   )fontsizezTime [s]zOrder of approximationZconvergence2X  dpi)r   arrayrangezeroslenpltr   gsGridSpecadd_subplotsetpget_xticklabelsr   init	enumerateprinttimeprocess_timer   d_1d0d1	transposescaplotylabelxlabelsavefig)compsn_listd_list	time_listfiggridaxsr   eosr   t0
analytical
label_listr
   r
   r   plot_convergence   s<    
rS   c                 C   s,  t dd tddD }t t|}t }|| d t|D ]@\}}td|d t	
 }t| |dd	g|d
}t	
 | ||< qDtd tjt||dd\}}	t ||d}
t t|t|d}tj|t||d |d ddd tj||dd tj|t |
|ddd td| td d S )Nc                 S   s   g | ]}|qS r
   r
   r   r
   r
   r   r   <   s     z!plot_time_fit.<locals>.<listcomp>      r   r    r!   r"   r#   r$   ZFitting)r   r   )p0   2   r   r   z--r'   )	linestyler)   r(   red:)r)   rY   zexp :Zruntime)r   r0   r1   r2   r3   r   r:   r;   r<   r=   r>   r   opt	curve_fitr   polyfitlinspaceminmaxr4   rD   polyvalrG   )rH   rI   rK   rO   r   r   rP   rQ   fit_polyZn_liner
   r
   r   plot_time_fit;   s$    "
rf   c                  C   s   t d } d S )Nz
298_files/)
plots_path)	save_pathr
   r
   r   	files_298T   s    ri   *  Fc                 C   s   |  d\}}t| d | }tddd}t }|| d tt|}	t|D ].\}
}t	| ||d| g|d}|j
| |	|
< qVtj||	|d	 td
| | |rtjdd tj|dd dS )a>  
    Plot soret coefficient from kinetic gas theory for N'th order approximation with different m2/m1 and sigma2/sigma1 ratios
    :param N (int): Order of approximation
    :param compare (bool): Use same limits as Tipton, Tompson and Loyalka
    :param save (str): Filename to save figure as (defaults to False)
    ,rd   r   g?rX   r   r   r$   )labelzPlotted for :r&   )titler-   r.   N)splitrg   r   r_   r   r:   r2   r3   r;   r   soretr4   rD   r<   legendrG   )rH   r&   Tsavecomp1comp2rh   x_listrO   
alpha_listr   xalpha_T0r
   r
   r   	plot_testW   s    ry   )rj   F)models.kineticgasr   pycThermopack.pyctpr   numpyr   matplotlib.pyplotpyplotr4   matplotlib.gridspecgridspecr5   r=   scipy.optimizeoptimizer\   Zmatplotlib.cmcm	root_path	data_pathrg   r   rS   rf   ri   ry   r
   r
   r
   r   <module>   s   *