B
    }N_2                 @   s`   d dl mZ d dlT d dlZd dlmZmZ d dlm	Z	 ddl
mZ ejZG dd	 d	ejZdS )
    )print_function)*N)platformexit)path   )thermoc                   s   e Zd ZdZ fddZd!ddZdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Z  ZS )"	saftvrmiez"
    Interface to SAFT-VR Mie
    c                sP  t t|   t| j| dd| _t| j| dd| _t| j| dd| _	t| j| dd| _
t| j| dd| _t| j| dd| _t| j| d	d
| _t| j| d	d| _t| j| d	d| _t| j| d	d| _t| j| d	d| _t| j| d	d| _t| j| d	d| _t| j| d	d| _dS )z=
        Initialize cubic specific function pointers
        Zsaftvrmie_optionsZ	enable_hsZ	enable_a1Z	enable_a2Z	enable_a3Zenable_chain
eoslibinitZinit_saftvrmieZsaftvrmie_containersZget_saftvrmie_pure_fluid_paramZset_saftvrmie_pure_fluid_paramZget_saftvrmie_eps_kijZset_saftvrmie_eps_kijZget_saftvrmie_sigma_lijZset_saftvrmie_sigma_lijZget_saftvrmie_lr_gammaijZset_saftvrmie_lr_gammaijN)superr	   __init__c_intin_dlltpget_export_nameenable_hs_cenable_a1_cenable_a2_cenable_a3_cenable_chain_cgetattrs_eoslibinit_init_saftvrmie s_get_saftvrmie_pure_fluid_param s_set_saftvrmie_pure_fluid_params_get_eps_kijs_set_eps_kijs_get_sigma_lijs_set_sigma_lijs_get_lr_gammaijs_set_lr_gammaij)self)	__class__ #../pycThermopack/pyctp/saftvrmie.pyr      s    zsaftvrmie.__init__Defaultc             C   s   t |d}tt|}t |d}tt|}t t ttg| j_d| j_| |||| tt|dt|d| _	dS )zInitialize SAFT-VR Mie model in thermopack

        Args:
            comps (str): Comma separated list of component names
            parameter_reference (str, optional): Which parameters to use?. Defaults to "Default".
        asciiN ,)
c_char_pencode
c_len_typelenr   argtypesrestypemaxsplitnc)r    compsparameter_referencecomp_string_ccomp_string_lenref_string_cref_string_lenr"   r"   r#   init3   s    
zsaftvrmie.initc             C   s   |rd| j _nd| j _dS )zModel control. Enable/disable hard-sphere term.

        Args:
            active (bool): Enable/disable hard-sphere dispersion term
        r   r   N)r   value)r    activer"   r"   r#   model_control_hard_sphereL   s    
z#saftvrmie.model_control_hard_spherec             C   s"   |rd| j _ntd d| j _dS )zModel control. Enable/disable first dispersion term.

        Args:
            active (bool): Enable/disable first dispersion term
        r   zeror   N)r   r8   print)r    r9   r"   r"   r#   model_control_a1W   s    
zsaftvrmie.model_control_a1c             C   s   |rd| j _nd| j _dS )zModel control. Enable/disable second dispersion term.

        Args:
            active (bool): Enable/disable second dispersion term
        r   r   N)r   r8   )r    r9   r"   r"   r#   model_control_a2c   s    
zsaftvrmie.model_control_a2c             C   s   |rd| j _nd| j _dS )zModel control. Enable/disable third dispersion term.

        Args:
            active (bool): Enable/disable third dispersion term
        r   r   N)r   r8   )r    r9   r"   r"   r#   model_control_a3n   s    
zsaftvrmie.model_control_a3c             C   s   |rd| j _nd| j _dS )zvModel control. Enable/disable chain term.

        Args:
            active (bool): Enable/disable chain term
        r   r   N)r   r8   )r    r9   r"   r"   r#   model_control_chainy   s    
zsaftvrmie.model_control_chainc             C   sZ   t |}t |}td}tt tt ttg| j_d| j_| t|t|t| |jS )zGet binary well depth interaction parameter

        Args:
            c1 (int): Component one
            c2 (int): Component two

        Returns:
            kij (float): Well depth interaction parameter
        g        N)r   c_doublePOINTERr   r,   r-   byrefr8   )r    c1c2c1_cc2_ckij_cr"   r"   r#   get_eps_kij   s    


zsaftvrmie.get_eps_kijc             C   sX   t |}t |}t|}tt tt ttg| j_d| j_| t|t|t| dS )zSet binary well depth interaction parameter

        Args:
            c1 (int): Component one
            c2 (int): Component two
            kij (float): Well depth interaction parameter
        N)r   rA   rB   r   r,   r-   rC   )r    rD   rE   kijrF   rG   rH   r"   r"   r#   set_eps_kij   s    
zsaftvrmie.set_eps_kijc             C   sZ   t |}t |}td}tt tt ttg| j_d| j_| t|t|t| |jS )a  Get the interaction parameter lij for the sigma combining rule (controlling non-additivity)

        Args:
            c1 (int): Component one
            c2 (int): Component two

        Returns:
            lij (float): Sigma interaction parameter
        g        N)r   rA   rB   r   r,   r-   rC   r8   )r    rD   rE   rF   rG   lij_cr"   r"   r#   get_sigma_lij   s    


zsaftvrmie.get_sigma_lijc             C   sX   t |}t |}t|}tt tt ttg| j_d| j_| t|t|t| dS )zSet the interaction parameter lij for the sigma combining rule (controlling non-additivity)

        Args:
            c1 (int): Component one
            c2 (int): Component two
            lij (float): Sigma interaction parameter
        N)r   rA   rB   r   r,   r-   rC   )r    rD   rE   lijrF   rG   rL   r"   r"   r#   set_sigma_lij   s    
zsaftvrmie.set_sigma_lijc             C   sZ   t |}t |}td}tt tt ttg| j_d| j_| t|t|t| |jS )zGet the interaction parameter gammaij for the lambda_r combining rule

        Args:
            c1 (int): Component one
            c2 (int): Component two

        Returns:
            gammaij (float): Repulsive exponent interaction parameter
        g        N)r   rA   rB   r   r,   r-   rC   r8   )r    rD   rE   rF   rG   	gammaij_cr"   r"   r#   get_lr_gammaij   s    


zsaftvrmie.get_lr_gammaijc             C   sX   t |}t |}t|}tt tt ttg| j_d| j_| t|t|t| dS )zSet the interaction parameter gammaij for the lambda_r combining rule

        Args:
            c1 (int): Component one
            c2 (int): Component two
            gammaij (float): Repulsive exponent interaction parameter
        N)r   rA   rB   r   r,   r-   rC   )r    rD   rE   ZgammaijrF   rG   rP   r"   r"   r#   set_lr_gammaij   s    
zsaftvrmie.set_lr_gammaijc          	   C   s   t |}td}td}td}td}td}tt ttttttttttg| j_d| j_| t|t|t|t|t|t| |j|j|j|j|jfS )a  Set pure fluid parameters

        Args:
            ic (int): Component index
        Returns;
            m (float): Mean number of segments.
            sigma (float): Temperature-independent segment diameter [m].
            eps_div_k (float): Well depth divided by Boltzmann's const. [K].
            lambda_a (float): Attractive exponent of the Mie potential
            lambda_r (float): Repulsive exponent of the Mie potential
        g        N)r   rA   rB   r   r,   r-   rC   r8   )r    icic_cm_csigma_ceps_c
lambda_a_c
lambda_r_cr"   r"   r#   get_pure_fluid_param  s(    

zsaftvrmie.get_pure_fluid_paramc          	   C   s   t |}t|}t|}	t|}
t|}t|}tt ttttttttttg| j_d| j_| t|t|t|	t|
t|t| dS )a  Set pure fluid parameters

        Args:
            ic (int): Component index
            m (float): Mean number of segments.
            sigma (float): Temperature-independent segment diameter [m].
            eps_div_k (float): Well depth divided by Boltzmann's const. [K].
            lambda_a (float): Attractive exponent of the Mie potential
            lambda_r (float): Repulsive exponent of the Mie potential
        N)r   rA   rB   r   r,   r-   rC   )r    rS   msigmaZ	eps_div_kZlambda_aZlambda_rrT   rU   rV   rW   rX   rY   r"   r"   r#   set_pure_fluid_param/  s&    
zsaftvrmie.set_pure_fluid_param)r$   )__name__
__module____qualname____doc__r   r7   r:   r=   r>   r?   r@   rI   rK   rM   rO   rQ   rR   rZ   r]   __classcell__r"   r"   )r!   r#   r	      s    
$r	   )
__future__r   ctypesnumpynpsysr   r   osr    r   r*   
thermopackr	   r"   r"   r"   r#   <module>   s   