B
    Xx^                 @   s^   d dl mZ d dlZd dlmZ d dlZd dl	Z	d dl
Z
dd ZdddZdd Zd	d
 ZdS )    Nc             C   s6   t jt jt j td| |   t jt j    }|S )N   )cT0_extrusionTi_extrusionnpexpw_extrusionrhoc_extrusion)thT r   O/Users/vegardjervell/Documents/6_semester/matmod/matmod11V4/extruded_profile.pyextr_eq	   s    2r   Fc          	   C   sv   d|  t jt j  }|dkrFt jt jt j ttj|| dd  S t jt jt j ttj|| dd  d S d S )Nr   Fr   )axesi  )r   r   r	   r   r   r   r   	tensordot)r
   r   celciusa1r   r   r   
T_func_vec   s    (r   c           	      s  t tjtjtjt jdddd} t jdddd}t jdddd}t jdd	d
d}t jd	ddd}t dg}t | |||||g}t dd |D t	
 }fdd|D }t	
 }	tdt dt|	| dddd d}
|
t fddtD  }td  fdd|D }tjddgd}d}x|t||D ]n\}}tj|d || dt|d  dd |d 7 }x2|d d  D ]"}tj||| d! |d 7 }qW qBW td" tjd#d$d% tjd&d$d% tjd'd$d( td) t  d S )*N
   2      )step      i  d   i  i  i'  c             S   s   g | ]}t |qS r   )len).0xr   r   r   
<listcomp>#   s    zplot_Tt.<locals>.<listcomp>c                s   g | ]}t  |d dqS )T)r   )r   )r   h_vals)t_listr   r   r   &   s    zCalculating T(h,t) in z points (all displayed) took    s )sepgffffff?c                s   g | ]}|  qS r   r   )r   i)	num_linesr   r   r   ,   s    YlOrRd_rc                s   g | ]} |qS r   r   )r   r   )cmapr   r   r   .   s          )figsizer   zh = :)colorlabel	linestyle   )r.   a  Temperature as a function of time in an extruded profile for different heat transfer coefficients.
Distance between lines is constant between each pair of dotted lines and equal $\frac{h}{10}$,
where $h$ is the highest heat transfer coefficient of the two dotted lines.zTime [s]   )fontsizeu   Temperature [℃]z
lower left)locr3   log)r   logspacer   t_min_extrusiont_max_extrusiont_points_extrusionarangearraysumtimeprocess_timeprintr   roundrangecmget_cmappltfigurezipplotstrtitlexlabelylabellegendxscalegrid)Zh1_listZh2_listZh3_listZh4_listZh5_listZh6_listh_listt0Z	all_tempst1	max_colorcolor_range
color_listfigZcolor_countZtemp_matrixr    	temp_listr   )r)   r'   r!   r   plot_Tt   s>    & 
(

rW   c              C   sx  t t tjt tjtj} tjtj dtj  t 	dtj
tj   }tjtj dtj  t 	tjtj tj
tj   }t t |t |d}t|| }|tjk|tjd k  }dt| }t j||d}t |}t |t |d gf}t ||}	ddtj |	tj   }
tjddgd}t| |
 td	 tjd
dd tjddd tjdd d S )Nr1   i  r   r*   r+   )r,   r5   z9Heat transfer coefficient, $\left[\frac{W}{m^2 K}\right]$r2   )r3   z)Fraction of transformation completion [-]both)which) r   r6   log10r   h_minh_maxh_stepsr   r	   r5   r   r   Teqr   c_curvest_star_funcmaMaskedArrayfilleddiffconcatenater;   dotXcnrD   rE   rG   rM   rJ   rK   rN   )rO   Zt_maxZt_minr!   rV   mask	integrandZmasked_integranddtIZfraction_listrU   r   r   r   plot_XhB   s$     ,4


ro   )F)matplotlib.pyplotpyplotrD   numpyr   Zmatplotlib.cmrB   	constantsr   r=   ra   r   r   rW   ro   r   r   r   r   <module>   s   
	+