B
    d^^=	                 @   sl   d dl Z d dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlZd dlZdddejejfddZdd	 ZdS )
    N)display   i  Implicitc             C   s  |dkr$t j|||d\}}tj}nV|dkrXt j|||d\}}t|d |d  d}n"|dkrzt j|||d\}}tj}t| | d }t	j
|| |d}	tj||| d	|d
 t| d t| d d tj| || d	d tj||	dddttj d tj| |	ddd ttj| d}
ddt|
  |
 }
t|| dd }t  td|
 d t| d tt|d d  td td tdttjtjg ttj d tjd  t  d S )Nr   )Tt_stopdtExplicitr   r      zCrank-Nicholson)r   bluez numerical solution
dx = z	mm, dt = s)colorlabel)r   orangez--zAnalytical solution, k = )r   	linestyler   )r   r   )seconds    zTime : z
Temperature : zK
Total concentration : zwt%zPosition [mm]zConcentration [wt%])
num_losereZ	implisittcdx_impZ
eksplisittroundZcrank_nicholsonZdx_crankint
analyticalZconspltZplotstrZanalytical_kdatetime	timedeltalennpmeanlegendtitleZxlabelZylabelZylimmaxZC0CsZxlimLshow)tr   solverr   end_timeCZx_pointsZdxZ	time_stepZanalytisk_ctimestrZ
total_cons r,   ;/Users/vegardjervell/Documents/6_semester/matmod8_2/main.pymain   s8    $,

r.   c              C   s   t jddd} t jddd}t jddddd}t jd	dtjtjd
}t jdddgdd}t |df|df t 	t 
|| |gt 
||gg}t jt|| ||d}tt 	||jd g d S )Ni  zTemp [K])valuedescriptionr   zTime [s]2   zdt [s])minr#   stepr0   r   )r/   r2   r#   r3   r   r   zCrank-NicholsonzSolver :)optionsr0   r/   )r'   r   r(   r   r   )widIntText	IntSliderPlayr   r   speedDropdownjslinkVBoxHBoxinteractiver.   r   children)ZTemptidr   Zplayr(   controlsoutputr,   r,   r-   run0   s    $rC   )r   r   	constantsr   numpyr   matplotlib.pyplotpyplotr   IPython.displayr   
ipywidgetsr5   r   r   r   r.   rC   r,   r,   r,   r-   <module>   s   %