a
    7bC;                     @   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dZ  ZS )"cubicz
    Interface to cubic
    c                    s   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| _dS )z=
        Initialize cubic specific function pointers
        Z
eoslibinitZ
init_cubic Zthermopack_getkijZthermopack_setkijandjiZthermopack_gethvparamZthermopack_sethvparamZthermopack_getwsparamZthermopack_setwsparamZ&thermopack_get_volume_shift_parametersZ&thermopack_set_volume_shift_parametersN)superr	   __init__getattrtpZget_export_nameeoslibinit_init_cubic	s_get_kij	s_set_kijs_get_hv_params_set_hv_params_get_ws_params_set_ws_params_get_cis_set_ci)self	__class__ [/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/pyctp/cubic.pyr      s    zcubic.__init__vdWClassicDefaultFc                 C   s  |    t|d}tt|}t|d}	tt|}
t|d}tt|}t|d}tt|}t|d}tt|}|rtd}ntd}ttttttttttttg| j_d| j_	| |||	||t
||||
|| tt|dt|d| _dS )a  Initialize cubic model in thermopack

        Args:
            comps (str): Comma separated list of component names
            eos (str): Equation of state (SRK, PR, ...)
            mixing (str, optional): Mixture model. Defaults to "vdW".
            alpha (str, optional): Alpha model. Defaults to "Classic".
            parameter_reference (str, optional): Which parameters to use?. Defaults to "Default".
        asciir   r   N ,)activatec_char_pencode
c_len_typelenc_intPOINTERr   argtypesrestypebyrefmaxsplitZnc)r   compsZeosZmixingalphaZparameter_referenceZvolume_shiftZeos_cZeos_lenZmixing_cZ
mixing_lenZalpha_cZ	alpha_lenZcomp_string_cZcomp_string_lenZref_string_cZref_string_lenZvol_shift_cr   r   r   init.   sP    
z
cubic.initc                 C   sb   |    t|}t|}td}ttttttg| j_d| j_| t|t|t| |jS )zGet attractive energy interaction parameter

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

        Returns:
            kij (float): i-j interaction parameter
                N)	r#   r(   c_doubler)   r   r*   r+   r,   value)r   c1c2c1_cc2_ckij_cr   r   r   get_kije   s    

zcubic.get_kijc                 C   s`   |    t|}t|}t|}ttttttg| j_d| j_| t|t|t| dS )zSet attractive energy interaction parameter

        Args:
            c1 (int): Component one
            c2 (int): Component two
            kij (float): i-j interaction parameter
        N)r#   r(   r3   r)   r   r*   r+   r,   )r   r5   r6   Zkijr7   r8   r9   r   r   r   set_kij   s    
zcubic.set_kijc                 C   s   dS )zGet co-volume interaction

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

        Returns:
            lij (float): i-j interaction parameter
        g      ?r   )r   r5   r6   r   r   r   get_lij   s    
zcubic.get_lijc                 C   s   t d dS )zSet co-volume interaction

        Args:
            c1 (int): Component one
            c2 (int): Component two
            lij ([type]): [description]
        zSetting lijN)print)r   r5   r6   Zlijr   r   r   set_lij   s    zcubic.set_lijc                 C   s  |    t|}t|}td}td}td}td}td}	td}
td}td}tt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|t|	t|
t|t|
 |j|j|j|j|	j|
j|j|jfS )a  Get Huron-Vidal parameters

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

        Returns:
            alpha_ij (float): alpha param i-j
            alpha_ji (float): alpha param j-i
            a_ij (float): a param i-j
            a_ji (float): a param j-i
            b_ij (float): b param i-j
            b_ji (float): b param j-i
            c_ij (float): c param i-j
            c_ji (float): c param j-i
        r2   N)	r#   r(   r3   r)   r   r*   r+   r,   r4   )r   r5   r6   r7   r8   
alpha_ij_c
alpha_ji_ca_ij_ca_ji_cb_ij_cb_ji_cc_ij_cc_ji_cr   r   r   get_hv_param   sF    

zcubic.get_hv_paramc                 C   s   |    t|}t|}t|}t|}t|}t|}t|}t|}t|	}t|
}tt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|t|t|t|t|
 dS )a  Set Huron-Vidal parameters

        Args:
            c1 (int): Component one
            c2 (int): Component two
            alpha_ij (float): alpha param i-j
            alpha_ji (float): alpha param j-i
            a_ij (float): a param i-j
            a_ji (float): a param j-i
            b_ij (float): b param i-j
            b_ji (float): b param j-i
            c_ij (float): c param i-j
            c_ji (float): c param j-i
        N)r#   r(   r3   r)   r   r*   r+   r,   )r   r5   r6   alpha_ijalpha_jiZa_ijZa_jiZb_ijZb_jiZc_ijZc_jir7   r8   r?   r@   rA   rB   rC   rD   rE   rF   r   r   r   set_hv_param   sD    
zcubic.set_hv_paramc                 C   s   |    t|}t|}td}td}td}td}td}	td}
ttttg| j_d| j_| t|t|t|t|t|t|t|	t|
 |j|j|j|j|	j|
jfS )a  Get Wong-Sandler parameters

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

        Returns:
            alpha_ij (float): alpha param i-j
            alpha_ji (float): alpha param j-i
            k_ij (float): k param i-j
            k_ji (float): k param j-i
            tau_ij (float): tau param i-j
            tau_ji (float): tau param j-i
        r2   N)	r#   r(   r3   r)   r   r*   r+   r,   r4   )r   r5   r6   r7   r8   r?   r@   k_ij_ck_ji_ctau_ij_ctau_ji_cr   r   r   get_ws_param  s.    
zcubic.get_ws_paramc	                 C   s   |    t|}	t|}
t|}t|}t|}t|}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|t|t| dS )aw  Set Wong-Sandler parameters

        Args:
            c1 (int): Component one
            c2 (int): Component two
            alpha_ij (float): alpha param i-j
            alpha_ji (float): alpha param j-i
            k_ij (float): k param i-j
            k_ji (float): k param j-i
            tau_ij (float): tau param i-j
            tau_ji (float): tau param j-i
        N)r#   r(   r3   r)   r   r*   r+   r,   )r   r5   r6   rH   rI   Zk_ijZk_jiZtau_ijZtau_jir7   r8   r?   r@   rK   rL   rM   rN   r   r   r   set_ws_param=  s8    	
zcubic.set_ws_paramc                 C   s   t |}td}td}td}t d}tt tttttttt g| j_d| j_| t|t|t|t|t| |j|j|j|jfS )a  Get volume correction parameters

        Args:
            cidx (int): Component index

        Returns:
            ciA (float): Volume shift param of component cidx (m3/mol)
            ciB (float): Volume shift param of component cidx (m3/mol/K)
            ciC (float): Volume shift param of component cidx (m3/mol/K^2)
            ci_type (int): Volume shift type (CONSTANT=1, LINEAR=2, QUADRATIC=3)
        r2   r   N)r(   r3   r)   r   r*   r+   r,   r4   )r   cidxcidx_cciA_cciB_cciC_c	ci_type_cr   r   r   get_cii  s&    
zcubic.get_cir2   r   c                 C   s   t |}t|}t|}t|}	t |}
tt tttttttt g| j_d| j_| t|t|t|t|	t|
 dS )a  Set volume correction parametrs

        Args:
            cidx (int): Component index
            ciA (float): Volume shift param of component cidx (m3/mol)
            ciB (float): Volume shift param of component cidx (m3/mol/K)
            ciC (float): Volume shift param of component cidx (m3/mol/K^2)
            ci_type (int): Volume shift type (CONSTANT=1, LINEAR=2, QUADRATIC=3)
        N)r(   r3   r)   r   r*   r+   r,   )r   rQ   ZciAZciBZciCZci_typerR   rS   rT   rU   rV   r   r   r   set_ci  s$    

zcubic.set_ci)r   r   r   F)r2   r2   r   )__name__
__module____qualname____doc__r   r1   r:   r;   r<   r>   rG   rJ   rO   rP   rW   rX   __classcell__r   r   r   r   r	      s     
7
64',!r	   )
__future__r   ctypesZnumpynpsysr   r   osr   r
   r   r&   Z
thermopackr	   r   r   r   r   <module>   s   