B
    _                 @   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	   [/Users/vegardjervell/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< x,tddD ]}|j	|| |d d||< qW x&tdD ]}tj
||  dd qW t }|| d x`t|D ]T\}}	td|	d t }
t| |ddg|	d}t |
 ||< |j|j|jg||< qW | }dddg}xFtdD ]:}t||  tj||| dd tj|| dd qdW t|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   g?)ncolsnrowsfigurehspacec             S   s   g | ]}d qS )Nr	   )r   r   r	   r	   r
   r      s    r   )sharexF)visibleSRK	Computingzorder approximationg?g?)
mole_fracsNz$d_{-1}$z$d_0$z$d_1$black)color   )fontsizezTime [s]zOrder of approximationZconvergence2iX  )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<    
rI   c             C   s0  t dd tddD }t t|}t }|| d xLt|D ]@\}}td|d t	
 }t| |dd	g|d
}t	
 | ||< qFW t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
   r   <   s    z!plot_time_fit.<locals>.<listcomp>      r   r   zorder approximationg?g?)r   r   ZFitting)r   r   )p0   2   r   r   z--r    )	linestyler!   )r!   red:)r!   rO   zexp :Zruntime)r   r&   r'   r(   r)   r   r0   r1   r2   r3   r4   r   opt	curve_fitr   polyfitlinspaceminmaxr*   r:   polyvalr=   )r>   r?   rA   rE   r   r   rF   rG   fit_polyZn_liner	   r	   r
   plot_time_fit;   s$    "
r\   c              C   s   t d } d S )Nz
298_files/)
plots_path)	save_pathr	   r	   r
   	files_298T   s    r_   *  Fc             C   s   |  d\}}t| d | }tddd}t }|| d tt|}	x:t|D ].\}
}t	| ||d| g|d}|j
| |	|
< qXW t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)
    ,rZ   g?g?rN   r   r   )r   r   )labelzPlotted for :r   )titleiX  )r%   N)splitr]   r   rU   r   r0   r(   r)   r1   r   soretr*   r:   r2   legendr=   )r>   r   Tsavecomp1comp2r^   x_listrE   
alpha_listr   xalpha_T0r	   r	   r
   	plot_testW   s    ro   )r`   F)models.kineticgasr   pycThermopack.pyctpr   numpyr   matplotlib.pyplotpyplotr*   matplotlib.gridspecgridspecr+   r3   scipy.optimizeoptimizerR   Zmatplotlib.cmcm	root_path	data_pathr]   r   rI   r\   r_   ro   r	   r	   r	   r
   <module>   s   *