a
     ɝhi                     @   s   d dl Z d dlZd dlZe je jeZe jeZeejvrNej	e d dl
mZ d dlmZ d dlmZ d dlZd dlZd dlZdd Zdd ZdS )    Nc                 C   st   d}d| d j d  d| d j d  d| d j d  d	| d
 j d  d| d j d  d| d| d j d  d}|S )NzG$$\kappa_L=\frac{G \upsilon_s V^{\frac{1}{3}}}{N T} \cdot e^{-\gamma}$$z4
            The volume of the crystal structure is    Volume (Å3)r   uF    Å$^3$.<br>
            The Bulk modulus of the crystal structure is Bulk modulus (GPa)zD GPa.<br>
            The Shear modulus of the crystal structure is Shear modulus (GPa)zE GPa.<br>
            The sound velocity of the crystal structure is Speed of sound (m s-1)zI m/s.<br>
            The Grunisen parameter of the crystal structure is    Grüneisen parameterzF.<br>
            The formula of the lattice thermal conductivity is: zA.<br>
            The calculated lattice thermal conductivity is Kappa_cal (W m-1 K-1)u    W/(m·K).<br>
            )iloc)dfformulatemplate r   $/var/www/html/AI4Kappa/Pages/PINK.pydisplay_results   s"    	r   c               
   C   s  t d tjd} t jj}tj| d}t jjr|t		tj|d}t
t|D ]P}|| }t|rnqVtj|}t | d t| t d| d qVt|\}}tt		tj|dr|d }t|}	tj| d	}
t|\}}z8t|d |  t| t|
|d }W t|  nt|  0 t|d
d  |d
d  D ]Z\}}zBt||  t| t|
|}tj||ddd}W t|  nt|  0 q^zzZt d t|}|jrt d W W t | d S tj||ddd}|jr0t d W W t | d S t!"|}t!#|}t!$|}g d}|j%d d |f }|jrt d W W t | d S t &| t d t|j'dkr|j'd nd}t d|  t d t j|	dd t d |jst(|}t j)|dd t d W nD t*y^ } z*t dt+|  t d W Y d }~n
d }~0 0 W t | nt | 0 n
t ,d t - " d}t j)|dd W d    n1 s0    Y  d S )NzIPhysics-informed machine learning for lattice thermal conductivity (PINK).modelz*.cifz% Invalid CIF file with no structures!z5In order to prevent program errors, invalid CIF file z has been deleted.r   ztest_results.csv   T)
left_indexright_indexz---z.Failed to extract crystal data from CIF files.z.Failed to merge crystal data with predictions.)zNumber of AtomszDensity (g cm-3)r   zthe total atomic mass (amu)r   r   z-Sound velocity of the transverse wave (m s-1)z,Sound velocity of the longitude wave (m s-1)r   zPoisson ratior   zAcoustic Debye Temperature (K)r   z5No data was generated. Please check your input files.zNo filez,The file name of displaying crystalline is: z1The information of uploaded crystal structure is:)unsafe_allow_htmlzAn error occurred: z,Please check your input files and try again.z-Please upload CIF files in the sidebar first.an  <p style='font-size: 22px;'>We strive to have clear documentation and examples to help everyone with using PINK on their own. 
                        We will happily fix issues in the documentation and examples should you find any, 
                        however, we will not be able to offer extensive user support and training, except for our collaborators.</p>).sttitleospathabspathsession_stateroot_dir_pathjoinuploaded_filesglobrangelenfois_valid_cifbasenamewriteremovecreate_id_propget_crystalline_contentcmget_model_path
copy_modelpredictmainget_pre_dataframeclean_modelzippdmergeget_dir_crystalline_dataemptyerrordel_cif_filecalkcal_Debye_T	cal_gammaby_MTPloc	dataframeindexr   markdown	Exceptionstrinfo	container)	sour_pathr   
model_pathcif_path_listiZcif_file_pathZcif_namecif_name_listfirst_cif_pathcry_contentresults_csv_pathmodel_path_listmodel_name_listpre_df
model_namepre_df1
all_cry_dfwhole_info_dfDebye_dfgamma_dfK_dflsfinal_dffirst_indexr   edeclarationr   r   r   app$   s    





"



*

%









"

rY   )r   r   sysr   dirnamer   __file__current_dir
parent_dirappendstreamlit_scripts.file_opfile_opr!   streamlit_scripts.chang_modelchang_modelr(   streamlit_scripts.calculate_Kcalculate_Kr6   r+   	streamlitr   pandasr0   r   rY   r   r   r   r   <module>   s   
